Remove array::IntoIter::with_partial -- an artifact of the past, once used to create an IntoIter from its parts

This commit is contained in:
Maybe Waffle 2022-08-01 17:00:51 +04:00
parent f5485181ca
commit ef72349e38
2 changed files with 4 additions and 13 deletions

View File

@ -84,16 +84,6 @@ impl<T, const N: usize> IntoIter<T, N> {
IntoIterator::into_iter(array) IntoIterator::into_iter(array)
} }
/// Creates a new iterator from a partially initalized array.
///
/// # Safety
///
/// The caller must guarantee that all and only the `alive` elements of
/// `data` are initialized.
pub(crate) unsafe fn with_partial(data: [MaybeUninit<T>; N], alive: Range<usize>) -> Self {
Self { data, alive }
}
/// Creates an iterator over the elements in a partially-initialized buffer. /// Creates an iterator over the elements in a partially-initialized buffer.
/// ///
/// If you have a fully-initialized array, then use [`IntoIterator`]. /// If you have a fully-initialized array, then use [`IntoIterator`].

View File

@ -64,7 +64,7 @@ fn next(&mut self) -> Option<Self::Item> {
mem::forget(guard); mem::forget(guard);
self.remainder = { self.remainder = {
// SAFETY: `array` was initialized with `init` elements. // SAFETY: `array` was initialized with `init` elements.
Some(unsafe { array::IntoIter::with_partial(array, 0..init) }) Some(unsafe { array::IntoIter::new_unchecked(array, 0..init) })
}; };
} }
return None; return None;
@ -124,7 +124,8 @@ fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
let init = guard.init; let init = guard.init;
mem::forget(guard); mem::forget(guard);
// SAFETY: `array` was initialized with `init` elements. // SAFETY: `array` was initialized with `init` elements.
self.remainder = Some(unsafe { array::IntoIter::with_partial(array, 0..init) }); self.remainder =
Some(unsafe { array::IntoIter::new_unchecked(array, 0..init) });
} }
R::from_output(o) R::from_output(o)
} }
@ -305,7 +306,7 @@ fn next_back_remainder(&mut self) -> Option<()> {
// SAFETY: `array` was initialized with exactly `init` elements. // SAFETY: `array` was initialized with exactly `init` elements.
self.remainder = unsafe { self.remainder = unsafe {
array.get_unchecked_mut(..init).reverse(); array.get_unchecked_mut(..init).reverse();
Some(array::IntoIter::with_partial(array, 0..init)) Some(array::IntoIter::new_unchecked(array, 0..init))
}; };
Some(()) Some(())
} }