collections: Move push/pop docs to MutableSeq

This commit is contained in:
Brian Anderson 2014-07-11 12:01:06 -07:00
parent 5599b69b6d
commit 7c61bb7213
2 changed files with 23 additions and 23 deletions

View File

@ -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>;
}

View File

@ -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 {