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
@@ -1092,7 +1092,7 @@ impl<T, A: Allocator> Vec<T, A> {
1092
1092
/// #![feature(vec_into_raw_parts)]
1093
1093
/// let v: Vec<i32> = vec![-1, 0, 1];
1094
1094
///
1095
- /// let (ptr, len, cap) = v. into_raw_parts();
1095
+ /// let (ptr, len, cap) = Vec:: into_raw_parts(v );
1096
1096
///
1097
1097
/// let rebuilt = unsafe {
1098
1098
/// // We can now make changes to the components, such as
@@ -1105,8 +1105,8 @@ impl<T, A: Allocator> Vec<T, A> {
1105
1105
/// ```
1106
1106
#[ must_use = "losing the pointer will leak memory" ]
1107
1107
#[ unstable( feature = "vec_into_raw_parts" , reason = "new API" , issue = "65816" ) ]
1108
- pub fn into_raw_parts ( self ) -> ( * mut T , usize , usize ) {
1109
- let mut me = ManuallyDrop :: new ( self ) ;
1108
+ pub fn into_raw_parts ( vec : Self ) -> ( * mut T , usize , usize ) {
1109
+ let mut me = ManuallyDrop :: new ( vec ) ;
1110
1110
( me. as_mut_ptr ( ) , me. len ( ) , me. capacity ( ) )
1111
1111
}
1112
1112
@@ -1133,7 +1133,7 @@ impl<T, A: Allocator> Vec<T, A> {
1133
1133
///
1134
1134
/// let v: Vec<i32> = vec![-1, 0, 1];
1135
1135
///
1136
- /// let (ptr, len, cap) = v. into_parts();
1136
+ /// let (ptr, len, cap) = Vec:: into_parts(v );
1137
1137
///
1138
1138
/// let rebuilt = unsafe {
1139
1139
/// // We can now make changes to the components, such as
@@ -1147,8 +1147,8 @@ impl<T, A: Allocator> Vec<T, A> {
1147
1147
#[ must_use = "losing the pointer will leak memory" ]
1148
1148
#[ unstable( feature = "box_vec_non_null" , reason = "new API" , issue = "130364" ) ]
1149
1149
// #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
1150
- pub fn into_parts ( self ) -> ( NonNull < T > , usize , usize ) {
1151
- let ( ptr, len, capacity) = self . into_raw_parts ( ) ;
1150
+ pub fn into_parts ( vec : Self ) -> ( NonNull < T > , usize , usize ) {
1151
+ let ( ptr, len, capacity) = Self :: into_raw_parts ( vec ) ;
1152
1152
// SAFETY: A `Vec` always has a non-null pointer.
1153
1153
( unsafe { NonNull :: new_unchecked ( ptr) } , len, capacity)
1154
1154
}
@@ -1179,7 +1179,7 @@ impl<T, A: Allocator> Vec<T, A> {
1179
1179
/// v.push(0);
1180
1180
/// v.push(1);
1181
1181
///
1182
- /// let (ptr, len, cap, alloc) = v. into_raw_parts_with_alloc();
1182
+ /// let (ptr, len, cap, alloc) = Vec:: into_raw_parts_with_alloc(v );
1183
1183
///
1184
1184
/// let rebuilt = unsafe {
1185
1185
/// // We can now make changes to the components, such as
@@ -1193,8 +1193,8 @@ impl<T, A: Allocator> Vec<T, A> {
1193
1193
#[ must_use = "losing the pointer will leak memory" ]
1194
1194
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
1195
1195
// #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
1196
- pub fn into_raw_parts_with_alloc ( self ) -> ( * mut T , usize , usize , A ) {
1197
- let mut me = ManuallyDrop :: new ( self ) ;
1196
+ pub fn into_raw_parts_with_alloc ( vec : Self ) -> ( * mut T , usize , usize , A ) {
1197
+ let mut me = ManuallyDrop :: new ( vec ) ;
1198
1198
let len = me. len ( ) ;
1199
1199
let capacity = me. capacity ( ) ;
1200
1200
let ptr = me. as_mut_ptr ( ) ;
@@ -1229,7 +1229,7 @@ impl<T, A: Allocator> Vec<T, A> {
1229
1229
/// v.push(0);
1230
1230
/// v.push(1);
1231
1231
///
1232
- /// let (ptr, len, cap, alloc) = v. into_parts_with_alloc();
1232
+ /// let (ptr, len, cap, alloc) = Vec:: into_parts_with_alloc(v );
1233
1233
///
1234
1234
/// let rebuilt = unsafe {
1235
1235
/// // We can now make changes to the components, such as
@@ -1244,8 +1244,8 @@ impl<T, A: Allocator> Vec<T, A> {
1244
1244
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
1245
1245
// #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")]
1246
1246
// #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
1247
- pub fn into_parts_with_alloc ( self ) -> ( NonNull < T > , usize , usize , A ) {
1248
- let ( ptr, len, capacity, alloc) = self . into_raw_parts_with_alloc ( ) ;
1247
+ pub fn into_parts_with_alloc ( vec : Self ) -> ( NonNull < T > , usize , usize , A ) {
1248
+ let ( ptr, len, capacity, alloc) = Vec :: into_raw_parts_with_alloc ( vec ) ;
1249
1249
// SAFETY: A `Vec` always has a non-null pointer.
1250
1250
( unsafe { NonNull :: new_unchecked ( ptr) } , len, capacity, alloc)
1251
1251
}
@@ -3139,7 +3139,7 @@ impl<T, A: Allocator, const N: usize> Vec<[T; N], A> {
3139
3139
/// ```
3140
3140
#[ stable( feature = "slice_flatten" , since = "1.80.0" ) ]
3141
3141
pub fn into_flattened ( self ) -> Vec < T , A > {
3142
- let ( ptr, len, cap, alloc) = self . into_raw_parts_with_alloc ( ) ;
3142
+ let ( ptr, len, cap, alloc) = Vec :: into_raw_parts_with_alloc ( self ) ;
3143
3143
let ( new_len, new_cap) = if T :: IS_ZST {
3144
3144
( len. checked_mul ( N ) . expect ( "vec len overflow" ) , usize:: MAX )
3145
3145
} else {
0 commit comments