We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 374ad1b + f4c59b3 commit c309266Copy full SHA for c309266
src/libcore/array/iter.rs
@@ -92,6 +92,15 @@ where
92
mem::transmute::<&[MaybeUninit<T>], &[T]>(slice)
93
}
94
95
+
96
+ /// Returns a mutable slice of all elements that have not been yielded yet.
97
+ fn as_mut_slice(&mut self) -> &mut [T] {
98
+ // This transmute is safe, same as in `as_slice` above.
99
+ let slice = &mut self.data[self.alive.clone()];
100
+ unsafe {
101
+ mem::transmute::<&mut [MaybeUninit<T>], &mut [T]>(slice)
102
+ }
103
104
105
106
@@ -184,10 +193,9 @@ where
184
193
[T; N]: LengthAtMost32,
185
194
{
186
195
fn drop(&mut self) {
187
- // We simply drop each element via `for_each`. This should not incur
188
- // any significant runtime overhead and avoids adding another `unsafe`
189
- // block.
190
- self.by_ref().for_each(drop);
196
197
+ ptr::drop_in_place(self.as_mut_slice())
198
191
199
192
200
201
0 commit comments