@@ -973,6 +973,29 @@ impl<T> Vec<T> {
973
973
}
974
974
}
975
975
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
+
976
999
/// Removes the last element from a vector and returns it, or [`None`] if it
977
1000
/// is empty.
978
1001
///
@@ -1267,29 +1290,6 @@ impl<T: Clone> Vec<T> {
1267
1290
pub fn extend_from_slice ( & mut self , other : & [ T ] ) {
1268
1291
self . spec_extend ( other. iter ( ) )
1269
1292
}
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
- }
1293
1293
}
1294
1294
1295
1295
// Set the length of the vec when the `SetLenOnDrop` value goes out of scope.
0 commit comments