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.
1 parent 7babfc5 commit 9603a5fCopy full SHA for 9603a5f
library/core/src/array/iter/iter_inner.rs
@@ -177,15 +177,10 @@ impl<T> PolymorphicIter<[MaybeUninit<T>]> {
177
178
#[inline]
179
pub(super) fn peek_with<U>(&self, func: impl for<'b> FnOnce(Option<&'b T>) -> U) -> U {
180
- let tmp = self.alive.clone().next().map(|idx| {
+ func(self.alive.clone().next().map(|idx| {
181
// SAFETY: `idx` is in self.alive range
182
- unsafe { self.data.get_unchecked(idx).assume_init_read() }
183
- });
184
-
185
- let out = func(tmp.as_ref());
186
- // Avoid dropping before the item is consumed
187
- crate::mem::forget(tmp);
188
- out
+ unsafe { self.data.get_unchecked(idx).assume_init_ref() }
+ }));
189
}
190
191
0 commit comments