1
- //! A contiguous growable array type with heap-allocated contents, written
1
+ //! A contiguous growable array type with heap-allocated contents, writtenalloc/vec/
2
2
//! `Vec<T>`.
3
3
//!
4
4
//! Vectors have *O*(1) indexing, amortized *O*(1) push (to the end) and
@@ -1085,7 +1085,7 @@ impl<T, A: Allocator> Vec<T, A> {
1085
1085
/// #![feature(vec_into_raw_parts)]
1086
1086
/// let v: Vec<i32> = vec![-1, 0, 1];
1087
1087
///
1088
- /// let (ptr, len, cap) = v. into_raw_parts();
1088
+ /// let (ptr, len, cap) = Vec:: into_raw_parts(v );
1089
1089
///
1090
1090
/// let rebuilt = unsafe {
1091
1091
/// // We can now make changes to the components, such as
@@ -1098,8 +1098,8 @@ impl<T, A: Allocator> Vec<T, A> {
1098
1098
/// ```
1099
1099
#[ must_use = "losing the pointer will leak memory" ]
1100
1100
#[ unstable( feature = "vec_into_raw_parts" , reason = "new API" , issue = "65816" ) ]
1101
- pub fn into_raw_parts ( self ) -> ( * mut T , usize , usize ) {
1102
- let mut me = ManuallyDrop :: new ( self ) ;
1101
+ pub fn into_raw_parts ( vec : Self ) -> ( * mut T , usize , usize ) {
1102
+ let mut me = ManuallyDrop :: new ( vec ) ;
1103
1103
( me. as_mut_ptr ( ) , me. len ( ) , me. capacity ( ) )
1104
1104
}
1105
1105
@@ -1126,7 +1126,7 @@ impl<T, A: Allocator> Vec<T, A> {
1126
1126
///
1127
1127
/// let v: Vec<i32> = vec![-1, 0, 1];
1128
1128
///
1129
- /// let (ptr, len, cap) = v. into_parts();
1129
+ /// let (ptr, len, cap) = Vec:: into_parts(v );
1130
1130
///
1131
1131
/// let rebuilt = unsafe {
1132
1132
/// // We can now make changes to the components, such as
@@ -1140,8 +1140,8 @@ impl<T, A: Allocator> Vec<T, A> {
1140
1140
#[ must_use = "losing the pointer will leak memory" ]
1141
1141
#[ unstable( feature = "box_vec_non_null" , reason = "new API" , issue = "130364" ) ]
1142
1142
// #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
1143
- pub fn into_parts ( self ) -> ( NonNull < T > , usize , usize ) {
1144
- let ( ptr, len, capacity) = self . into_raw_parts ( ) ;
1143
+ pub fn into_parts ( vec : Self ) -> ( NonNull < T > , usize , usize ) {
1144
+ let ( ptr, len, capacity) = Self :: into_raw_parts ( vec ) ;
1145
1145
// SAFETY: A `Vec` always has a non-null pointer.
1146
1146
( unsafe { NonNull :: new_unchecked ( ptr) } , len, capacity)
1147
1147
}
@@ -1172,7 +1172,7 @@ impl<T, A: Allocator> Vec<T, A> {
1172
1172
/// v.push(0);
1173
1173
/// v.push(1);
1174
1174
///
1175
- /// let (ptr, len, cap, alloc) = v. into_raw_parts_with_alloc();
1175
+ /// let (ptr, len, cap, alloc) = Vec:: into_raw_parts_with_alloc(v );
1176
1176
///
1177
1177
/// let rebuilt = unsafe {
1178
1178
/// // We can now make changes to the components, such as
@@ -1186,8 +1186,8 @@ impl<T, A: Allocator> Vec<T, A> {
1186
1186
#[ must_use = "losing the pointer will leak memory" ]
1187
1187
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
1188
1188
// #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
1189
- pub fn into_raw_parts_with_alloc ( self ) -> ( * mut T , usize , usize , A ) {
1190
- let mut me = ManuallyDrop :: new ( self ) ;
1189
+ pub fn into_raw_parts_with_alloc ( vec : Self ) -> ( * mut T , usize , usize , A ) {
1190
+ let mut me = ManuallyDrop :: new ( vec ) ;
1191
1191
let len = me. len ( ) ;
1192
1192
let capacity = me. capacity ( ) ;
1193
1193
let ptr = me. as_mut_ptr ( ) ;
@@ -1222,7 +1222,7 @@ impl<T, A: Allocator> Vec<T, A> {
1222
1222
/// v.push(0);
1223
1223
/// v.push(1);
1224
1224
///
1225
- /// let (ptr, len, cap, alloc) = v. into_parts_with_alloc();
1225
+ /// let (ptr, len, cap, alloc) = Vec:: into_parts_with_alloc(v );
1226
1226
///
1227
1227
/// let rebuilt = unsafe {
1228
1228
/// // We can now make changes to the components, such as
@@ -1237,8 +1237,8 @@ impl<T, A: Allocator> Vec<T, A> {
1237
1237
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
1238
1238
// #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")]
1239
1239
// #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
1240
- pub fn into_parts_with_alloc ( self ) -> ( NonNull < T > , usize , usize , A ) {
1241
- let ( ptr, len, capacity, alloc) = self . into_raw_parts_with_alloc ( ) ;
1240
+ pub fn into_parts_with_alloc ( vec : Self ) -> ( NonNull < T > , usize , usize , A ) {
1241
+ let ( ptr, len, capacity, alloc) = Vec :: into_raw_parts_with_alloc ( vec ) ;
1242
1242
// SAFETY: A `Vec` always has a non-null pointer.
1243
1243
( unsafe { NonNull :: new_unchecked ( ptr) } , len, capacity, alloc)
1244
1244
}
@@ -3132,7 +3132,7 @@ impl<T, A: Allocator, const N: usize> Vec<[T; N], A> {
3132
3132
/// ```
3133
3133
#[ stable( feature = "slice_flatten" , since = "1.80.0" ) ]
3134
3134
pub fn into_flattened ( self ) -> Vec < T , A > {
3135
- let ( ptr, len, cap, alloc) = self . into_raw_parts_with_alloc ( ) ;
3135
+ let ( ptr, len, cap, alloc) = Vec :: into_raw_parts_with_alloc ( self ) ;
3136
3136
let ( new_len, new_cap) = if T :: IS_ZST {
3137
3137
( len. checked_mul ( N ) . expect ( "vec len overflow" ) , usize:: MAX )
3138
3138
} else {
0 commit comments