1- //! A contiguous growable array type with heap-allocated contents, written
1+ //! A contiguous growable array type with heap-allocated contents, writtenalloc/vec/
22//! `Vec<T>`.
33//!
44//! Vectors have *O*(1) indexing, amortized *O*(1) push (to the end) and
@@ -1092,7 +1092,7 @@ impl<T, A: Allocator> Vec<T, A> {
10921092 /// #![feature(vec_into_raw_parts)]
10931093 /// let v: Vec<i32> = vec![-1, 0, 1];
10941094 ///
1095- /// let (ptr, len, cap) = v. into_raw_parts();
1095+ /// let (ptr, len, cap) = Vec:: into_raw_parts(v );
10961096 ///
10971097 /// let rebuilt = unsafe {
10981098 /// // We can now make changes to the components, such as
@@ -1105,8 +1105,8 @@ impl<T, A: Allocator> Vec<T, A> {
11051105 /// ```
11061106 #[ must_use = "losing the pointer will leak memory" ]
11071107 #[ 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 ) ;
11101110 ( me. as_mut_ptr ( ) , me. len ( ) , me. capacity ( ) )
11111111 }
11121112
@@ -1133,7 +1133,7 @@ impl<T, A: Allocator> Vec<T, A> {
11331133 ///
11341134 /// let v: Vec<i32> = vec![-1, 0, 1];
11351135 ///
1136- /// let (ptr, len, cap) = v. into_parts();
1136+ /// let (ptr, len, cap) = Vec:: into_parts(v );
11371137 ///
11381138 /// let rebuilt = unsafe {
11391139 /// // We can now make changes to the components, such as
@@ -1147,8 +1147,8 @@ impl<T, A: Allocator> Vec<T, A> {
11471147 #[ must_use = "losing the pointer will leak memory" ]
11481148 #[ unstable( feature = "box_vec_non_null" , reason = "new API" , issue = "130364" ) ]
11491149 // #[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 ) ;
11521152 // SAFETY: A `Vec` always has a non-null pointer.
11531153 ( unsafe { NonNull :: new_unchecked ( ptr) } , len, capacity)
11541154 }
@@ -1179,7 +1179,7 @@ impl<T, A: Allocator> Vec<T, A> {
11791179 /// v.push(0);
11801180 /// v.push(1);
11811181 ///
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 );
11831183 ///
11841184 /// let rebuilt = unsafe {
11851185 /// // We can now make changes to the components, such as
@@ -1193,8 +1193,8 @@ impl<T, A: Allocator> Vec<T, A> {
11931193 #[ must_use = "losing the pointer will leak memory" ]
11941194 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
11951195 // #[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 ) ;
11981198 let len = me. len ( ) ;
11991199 let capacity = me. capacity ( ) ;
12001200 let ptr = me. as_mut_ptr ( ) ;
@@ -1229,7 +1229,7 @@ impl<T, A: Allocator> Vec<T, A> {
12291229 /// v.push(0);
12301230 /// v.push(1);
12311231 ///
1232- /// let (ptr, len, cap, alloc) = v. into_parts_with_alloc();
1232+ /// let (ptr, len, cap, alloc) = Vec:: into_parts_with_alloc(v );
12331233 ///
12341234 /// let rebuilt = unsafe {
12351235 /// // We can now make changes to the components, such as
@@ -1244,8 +1244,8 @@ impl<T, A: Allocator> Vec<T, A> {
12441244 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
12451245 // #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")]
12461246 // #[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 ) ;
12491249 // SAFETY: A `Vec` always has a non-null pointer.
12501250 ( unsafe { NonNull :: new_unchecked ( ptr) } , len, capacity, alloc)
12511251 }
@@ -3139,7 +3139,7 @@ impl<T, A: Allocator, const N: usize> Vec<[T; N], A> {
31393139 /// ```
31403140 #[ stable( feature = "slice_flatten" , since = "1.80.0" ) ]
31413141 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 ) ;
31433143 let ( new_len, new_cap) = if T :: IS_ZST {
31443144 ( len. checked_mul ( N ) . expect ( "vec len overflow" ) , usize:: MAX )
31453145 } else {
0 commit comments