collections: Move push/pop docs to MutableSeq
This commit is contained in:
parent
5599b69b6d
commit
7c61bb7213
@ -326,7 +326,30 @@ pub trait MutableSet<T>: Set<T> + Mutable {
|
||||
}
|
||||
|
||||
pub trait MutableSeq<T>: Mutable {
|
||||
/// Append an element to the back of a collection.
|
||||
///
|
||||
/// # Failure
|
||||
///
|
||||
/// Fails if the number of elements in the vector overflows a `uint`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let mut vec = vec!(1i, 2);
|
||||
/// vec.push(3);
|
||||
/// assert_eq!(vec, vec!(1, 2, 3));
|
||||
/// ```
|
||||
fn push(&mut self, t: T);
|
||||
/// Remove the last element from a collection and return it, or `None` if it is
|
||||
/// empty.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let mut vec = vec!(1i, 2, 3);
|
||||
/// assert_eq!(vec.pop(), Some(3));
|
||||
/// assert_eq!(vec, vec!(1, 2));
|
||||
/// ```
|
||||
fn pop(&mut self) -> Option<T>;
|
||||
}
|
||||
|
||||
|
@ -1555,19 +1555,6 @@ impl<T:fmt::Show> fmt::Show for Vec<T> {
|
||||
}
|
||||
|
||||
impl<T> MutableSeq<T> for Vec<T> {
|
||||
/// Append an element to a vector.
|
||||
///
|
||||
/// # Failure
|
||||
///
|
||||
/// Fails if the number of elements in the vector overflows a `uint`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let mut vec = vec!(1i, 2);
|
||||
/// vec.push(3);
|
||||
/// assert_eq!(vec, vec!(1, 2, 3));
|
||||
/// ```
|
||||
#[inline]
|
||||
fn push(&mut self, value: T) {
|
||||
if mem::size_of::<T>() == 0 {
|
||||
@ -1594,16 +1581,6 @@ impl<T> MutableSeq<T> for Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove the last element from a vector and return it, or `None` if it is
|
||||
/// empty.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// let mut vec = vec!(1i, 2, 3);
|
||||
/// assert_eq!(vec.pop(), Some(3));
|
||||
/// assert_eq!(vec, vec!(1, 2));
|
||||
/// ```
|
||||
#[inline]
|
||||
fn pop(&mut self) -> Option<T> {
|
||||
if self.len == 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user