From ef72349e38635bc329a94b1e95648562e59ab7d2 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Mon, 1 Aug 2022 17:00:51 +0400 Subject: [PATCH] Remove `array::IntoIter::with_partial` -- an artifact of the past, once used to create an `IntoIter` from its parts --- library/core/src/array/iter.rs | 10 ---------- library/core/src/iter/adapters/array_chunks.rs | 7 ++++--- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs index 459cd094cdc..f4885ed9ffb 100644 --- a/library/core/src/array/iter.rs +++ b/library/core/src/array/iter.rs @@ -84,16 +84,6 @@ impl IntoIter { 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; N], alive: Range) -> Self { - Self { data, alive } - } - /// Creates an iterator over the elements in a partially-initialized buffer. /// /// If you have a fully-initialized array, then use [`IntoIterator`]. diff --git a/library/core/src/iter/adapters/array_chunks.rs b/library/core/src/iter/adapters/array_chunks.rs index 2ec1284c394..8f3e1b58b52 100644 --- a/library/core/src/iter/adapters/array_chunks.rs +++ b/library/core/src/iter/adapters/array_chunks.rs @@ -64,7 +64,7 @@ fn next(&mut self) -> Option { mem::forget(guard); self.remainder = { // 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; @@ -124,7 +124,8 @@ fn try_fold(&mut self, init: B, mut f: F) -> R let init = guard.init; mem::forget(guard); // 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) } @@ -305,7 +306,7 @@ fn next_back_remainder(&mut self) -> Option<()> { // SAFETY: `array` was initialized with exactly `init` elements. self.remainder = unsafe { array.get_unchecked_mut(..init).reverse(); - Some(array::IntoIter::with_partial(array, 0..init)) + Some(array::IntoIter::new_unchecked(array, 0..init)) }; Some(()) }