Skip to content

Commit

Permalink
Rollup merge of rust-lang#40909 - nagisa:fix-vec-placement, r=alexcri…
Browse files Browse the repository at this point in the history
…chton

Allow using Vec::<T>::place_back for T: !Clone

The place_back was likely put into block with `T: Clone` bound by mistake.
  • Loading branch information
Ariel Ben-Yehuda authored Apr 5, 2017
2 parents cee0508 + 1e3bc5a commit 1fdcb79
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 @@ -973,6 +973,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 @@ -1267,29 +1290,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 1fdcb79

Please sign in to comment.