Struct PolymorphicIter

pub(in ::array::iter) struct PolymorphicIter<DATA>
where
    DATA: PartialDrop + ?Sized, { pub(in ::array::iter::iter_inner) alive: IndexRange, pub(in ::array::iter::iter_inner) data: DATA }

The internals of a by-value array iterator.

The real array::IntoIter<T, N> stores a PolymorphicIter<[MaybeUninit<T>, N]> which it unsizes to PolymorphicIter<[MaybeUninit<T>]> to iterate.

Fields

alive: IndexRange

The elements in data that have not been yielded yet.

Invariants:

  • alive.end <= N

(And the IndexRange type requires alive.start <= alive.end.)

data: DATA

This is the array we are iterating over.

Elements with index i where alive.start <= i < alive.end have not been yielded yet and are valid array entries. Elements with indices i < alive.start or i >= alive.end have been yielded already and must not be accessed anymore! Those dead elements might even be in a completely uninitialized state!

So the invariants are:

  • data[alive] is alive (i.e. contains valid elements)
  • data[..alive.start] and data[alive.end..] are dead (i.e. the elements were already read and must not be touched anymore!)

Implementations

impl<DATA> PolymorphicIter<DATA> where DATA: PartialDrop + ?Sized,

const fn len(&self) -> usize

impl<T> PolymorphicIter<[MaybeUninit<T>]>

fn as_slice(&self) -> &[T]
const fn as_mut_slice(&mut self) -> &mut [T]

impl<T> PolymorphicIter<[MaybeUninit<T>]>

fn next(&mut self) -> Option<T>
fn size_hint(&self) -> (usize, Option<usize>)
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
fn fold<B>(&mut self, init: B, f: impl FnMut(B, T) -> B) -> B
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
where
    F: FnMut(B, T) -> R,
    R: Try<Output = B>,
fn next_back(&mut self) -> Option<T>
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
fn rfold<B>(&mut self, init: B, f: impl FnMut(B, T) -> B) -> B
fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
where
    F: FnMut(B, T) -> R,
    R: Try<Output = B>,

impl<T, const N: usize> PolymorphicIter<[MaybeUninit<T>; N]>

const fn empty() -> Self
const unsafe fn new_unchecked(alive: IndexRange, data: [MaybeUninit<T>; N]) -> Self

Safety

data[alive] are all initialized.

Trait Implementations

impl<DATA> Drop for PolymorphicIter<DATA> where DATA: PartialDrop + ?Sized,

fn drop(&mut self)

impl<T: Clone, const N: usize> Clone for PolymorphicIter<[MaybeUninit<T>; N]>

fn clone(&self) -> Self

impl<T: Debug> Debug for PolymorphicIter<[MaybeUninit<T>]>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<DATA> Freeze for PolymorphicIter<DATA> where DATA: Freeze + ?Sized,

impl<DATA> RefUnwindSafe for PolymorphicIter<DATA> where DATA: RefUnwindSafe + ?Sized,

impl<DATA> Send for PolymorphicIter<DATA> where DATA: Send + ?Sized,

impl<DATA> Sync for PolymorphicIter<DATA> where DATA: Sync + ?Sized,

impl<DATA> Unpin for PolymorphicIter<DATA> where DATA: Unpin + ?Sized,

impl<DATA> UnsafeUnpin for PolymorphicIter<DATA> where DATA: UnsafeUnpin + ?Sized,

impl<DATA> UnwindSafe for PolymorphicIter<DATA> where DATA: UnwindSafe + ?Sized,

Blanket Implementations

impl<T> Any for PolymorphicIter<DATA> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for PolymorphicIter<DATA> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for PolymorphicIter<DATA> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for PolymorphicIter<DATA> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for PolymorphicIter<DATA>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for PolymorphicIter<DATA> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for PolymorphicIter<DATA>

impl<T, U> Into<U> for PolymorphicIter<DATA> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for PolymorphicIter<DATA> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for PolymorphicIter<DATA> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>