Skip to content

Commit

Permalink
Allow using Vec::<T>::place_back for T: !Clone
Browse files Browse the repository at this point in the history
The place_back was likely put into block with `T: Clone` bound by mistake.
  • Loading branch information
nagisa committed Mar 29, 2017
1 parent e1cec5d commit 1e3bc5a
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,29 @@ impl<T> Vec<T> {
}
}

/// Returns a place for insertion at the back of the `Vec`.
///
/// Using this method with placement syntax is equivalent to [`push`](#method.push),
/// but may be more efficient.
///
/// # Examples
///
/// ```
/// #![feature(collection_placement)]
/// #![feature(placement_in_syntax)]
///
/// let mut vec = vec![1, 2];
/// vec.place_back() <- 3;
/// vec.place_back() <- 4;
/// assert_eq!(&vec, &[1, 2, 3, 4]);
/// ```
#[unstable(feature = "collection_placement",
reason = "placement protocol is subject to change",
issue = "30172")]
pub fn place_back(&mut self) -> PlaceBack<T> {
PlaceBack { vec: self }
}

/// Removes the last element from a vector and returns it, or [`None`] if it
/// is empty.
///
Expand Down Expand Up @@ -1266,29 +1289,6 @@ impl<T: Clone> Vec<T> {
pub fn extend_from_slice(&mut self, other: &[T]) {
self.spec_extend(other.iter())
}

/// Returns a place for insertion at the back of the `Vec`.
///
/// Using this method with placement syntax is equivalent to [`push`](#method.push),
/// but may be more efficient.
///
/// # Examples
///
/// ```
/// #![feature(collection_placement)]
/// #![feature(placement_in_syntax)]
///
/// let mut vec = vec![1, 2];
/// vec.place_back() <- 3;
/// vec.place_back() <- 4;
/// assert_eq!(&vec, &[1, 2, 3, 4]);
/// ```
#[unstable(feature = "collection_placement",
reason = "placement protocol is subject to change",
issue = "30172")]
pub fn place_back(&mut self) -> PlaceBack<T> {
PlaceBack { vec: self }
}
}

// Set the length of the vec when the `SetLenOnDrop` value goes out of scope.
Expand Down

0 comments on commit 1e3bc5a

Please sign in to comment.