use crate::{iter::ArrayChunks, Array};
pub trait IteratorExt: Iterator {
#[inline]
fn array_chunks<A>(self) -> ArrayChunks<Self, A>
where
Self: Sized,
A: Array<Item = Self::Item>,
{
assert!(A::SIZE > 0, "Size of chunks must be greater that zero");
ArrayChunks::new(self)
}
#[inline]
fn collect_array<A>(self) -> A
where
Self: Sized,
A: Array<Item = Self::Item>,
{
A::from_iter(self)
}
#[inline]
fn try_collect_array<A>(self) -> Option<A>
where
Self: Sized,
A: Array<Item = Self::Item>,
{
A::try_from_iter(self)
}
}
impl<I: Iterator + ?Sized> IteratorExt for I {}