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