Skip to content

Commit 1fdcb79

Browse files
author
Ariel Ben-Yehuda
authored
Rollup merge of rust-lang#40909 - nagisa:fix-vec-placement, r=alexcrichton
Allow using Vec::<T>::place_back for T: !Clone The place_back was likely put into block with `T: Clone` bound by mistake.
2 parents cee0508 + 1e3bc5a commit 1fdcb79

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/libcollections/vec.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,29 @@ impl<T> Vec<T> {
973973
}
974974
}
975975

976+
/// Returns a place for insertion at the back of the `Vec`.
977+
///
978+
/// Using this method with placement syntax is equivalent to [`push`](#method.push),
979+
/// but may be more efficient.
980+
///
981+
/// # Examples
982+
///
983+
/// ```
984+
/// #![feature(collection_placement)]
985+
/// #![feature(placement_in_syntax)]
986+
///
987+
/// let mut vec = vec![1, 2];
988+
/// vec.place_back() <- 3;
989+
/// vec.place_back() <- 4;
990+
/// assert_eq!(&vec, &[1, 2, 3, 4]);
991+
/// ```
992+
#[unstable(feature = "collection_placement",
993+
reason = "placement protocol is subject to change",
994+
issue = "30172")]
995+
pub fn place_back(&mut self) -> PlaceBack<T> {
996+
PlaceBack { vec: self }
997+
}
998+
976999
/// Removes the last element from a vector and returns it, or [`None`] if it
9771000
/// is empty.
9781001
///
@@ -1267,29 +1290,6 @@ impl<T: Clone> Vec<T> {
12671290
pub fn extend_from_slice(&mut self, other: &[T]) {
12681291
self.spec_extend(other.iter())
12691292
}
1270-
1271-
/// Returns a place for insertion at the back of the `Vec`.
1272-
///
1273-
/// Using this method with placement syntax is equivalent to [`push`](#method.push),
1274-
/// but may be more efficient.
1275-
///
1276-
/// # Examples
1277-
///
1278-
/// ```
1279-
/// #![feature(collection_placement)]
1280-
/// #![feature(placement_in_syntax)]
1281-
///
1282-
/// let mut vec = vec![1, 2];
1283-
/// vec.place_back() <- 3;
1284-
/// vec.place_back() <- 4;
1285-
/// assert_eq!(&vec, &[1, 2, 3, 4]);
1286-
/// ```
1287-
#[unstable(feature = "collection_placement",
1288-
reason = "placement protocol is subject to change",
1289-
issue = "30172")]
1290-
pub fn place_back(&mut self) -> PlaceBack<T> {
1291-
PlaceBack { vec: self }
1292-
}
12931293
}
12941294

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

0 commit comments

Comments
 (0)