@@ -9,7 +9,6 @@ use std::{
9
9
self ,
10
10
fmt:: { self , Debug } ,
11
11
hash:: { Hash , Hasher } ,
12
- mem:: ManuallyDrop ,
13
12
ops,
14
13
slice:: SliceIndex ,
15
14
} ;
@@ -35,7 +34,7 @@ use crate::{Allocator, Box};
35
34
/// Static checks make this impossible to do. [`Vec::new_in`] and all other methods which create
36
35
/// a [`Vec`] will refuse to compile if called with a [`Drop`] type.
37
36
#[ derive( PartialEq , Eq ) ]
38
- pub struct Vec < ' alloc , T > ( pub ( crate ) ManuallyDrop < InnerVec < ' alloc , T > > ) ;
37
+ pub struct Vec < ' alloc , T > ( InnerVec < ' alloc , T > ) ;
39
38
40
39
/// SAFETY: Not actually safe, but for enabling `Send` for downstream crates.
41
40
unsafe impl < T > Send for Vec < ' _ , T > { }
@@ -65,7 +64,7 @@ impl<'alloc, T> Vec<'alloc, T> {
65
64
pub fn new_in ( allocator : & ' alloc Allocator ) -> Self {
66
65
const { Self :: ASSERT_T_IS_NOT_DROP } ;
67
66
68
- Self ( ManuallyDrop :: new ( InnerVec :: new_in ( allocator. bump ( ) ) ) )
67
+ Self ( InnerVec :: new_in ( allocator. bump ( ) ) )
69
68
}
70
69
71
70
/// Constructs a new, empty `Vec<T>` with at least the specified capacity
@@ -118,7 +117,7 @@ impl<'alloc, T> Vec<'alloc, T> {
118
117
pub fn with_capacity_in ( capacity : usize , allocator : & ' alloc Allocator ) -> Self {
119
118
const { Self :: ASSERT_T_IS_NOT_DROP } ;
120
119
121
- Self ( ManuallyDrop :: new ( InnerVec :: with_capacity_in ( capacity, allocator. bump ( ) ) ) )
120
+ Self ( InnerVec :: with_capacity_in ( capacity, allocator. bump ( ) ) )
122
121
}
123
122
124
123
/// Create a new [`Vec`] whose elements are taken from an iterator and
@@ -132,7 +131,7 @@ impl<'alloc, T> Vec<'alloc, T> {
132
131
let iter = iter. into_iter ( ) ;
133
132
let hint = iter. size_hint ( ) ;
134
133
let capacity = hint. 1 . unwrap_or ( hint. 0 ) ;
135
- let mut vec = ManuallyDrop :: new ( InnerVec :: with_capacity_in ( capacity, allocator. bump ( ) ) ) ;
134
+ let mut vec = InnerVec :: with_capacity_in ( capacity, allocator. bump ( ) ) ;
136
135
vec. extend ( iter) ;
137
136
Self ( vec)
138
137
}
@@ -163,7 +162,7 @@ impl<'alloc, T> Vec<'alloc, T> {
163
162
// `len` and `capacity` are both `N`.
164
163
// Allocated size cannot be larger than `isize::MAX`, or `Box::new_in` would have failed.
165
164
let vec = unsafe { InnerVec :: from_raw_parts_in ( ptr, N , N , allocator. bump ( ) ) } ;
166
- Self ( ManuallyDrop :: new ( vec) )
165
+ Self ( vec)
167
166
}
168
167
}
169
168
@@ -189,10 +188,7 @@ impl<'alloc, T> IntoIterator for Vec<'alloc, T> {
189
188
190
189
#[ inline( always) ]
191
190
fn into_iter ( self ) -> Self :: IntoIter {
192
- let inner = ManuallyDrop :: into_inner ( self . 0 ) ;
193
- // TODO: `allocator_api2::vec::Vec::IntoIter` is `Drop`.
194
- // Wrap it in `ManuallyDrop` to prevent that.
195
- inner. into_iter ( )
191
+ self . 0 . into_iter ( )
196
192
}
197
193
}
198
194
@@ -261,8 +257,7 @@ impl<T: Hash> Hash for Vec<'_, T> {
261
257
262
258
impl < T : Debug > Debug for Vec < ' _ , T > {
263
259
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
264
- let inner = & * self . 0 ;
265
- f. debug_tuple ( "Vec" ) . field ( inner) . finish ( )
260
+ f. debug_tuple ( "Vec" ) . field ( & self . 0 ) . finish ( )
266
261
}
267
262
}
268
263
0 commit comments