Struct iter_fixed::IteratorFixed [−][src]
pub struct IteratorFixed<I: Iterator, const N: usize> { /* fields omitted */ }
Expand description
Iterator of fixed size
A type that can be usen a bit like an ordinary Iterator but with a compile time guaranteed length. This enables us to turn them back into collections of fixed size without having to perform unnecessary checks during run time.
Just like Iterator, IteratorFixed provides a lot of methods like:
map
inspect
skip
step_by
chain
enumerate
take
zip
rev
copied
cloned
however it does not support methods like filter
or take_while
which will affect the length during runtime.
Implementations
impl<I, const N: usize> IteratorFixed<I, N> where
I: Iterator,
[src]
impl<I, const N: usize> IteratorFixed<I, N> where
I: Iterator,
[src]pub unsafe fn from_iter<II: IntoIterator<IntoIter = I>>(i: II) -> Self
[src]
pub unsafe fn from_iter<II: IntoIterator<IntoIter = I>>(i: II) -> Self
[src]Safety
Caller has to guarantee that the given iterator will yield exactly N elements
pub fn map<U, F: FnMut(<I as Iterator>::Item) -> U>(
self,
p: F
) -> IteratorFixed<impl Iterator<Item = U>, N>
[src]
pub fn map<U, F: FnMut(<I as Iterator>::Item) -> U>(
self,
p: F
) -> IteratorFixed<impl Iterator<Item = U>, N>
[src]pub fn inspect<F: FnMut(&<I as Iterator>::Item)>(
self,
p: F
) -> IteratorFixed<impl Iterator<Item = I::Item>, N>
[src]
pub fn inspect<F: FnMut(&<I as Iterator>::Item)>(
self,
p: F
) -> IteratorFixed<impl Iterator<Item = I::Item>, N>
[src]pub fn skip<const SKIP: usize>(
self
) -> IteratorFixed<impl Iterator<Item = I::Item>, { sub_or_zero(N, SKIP) }>
[src]
pub fn skip<const SKIP: usize>(
self
) -> IteratorFixed<impl Iterator<Item = I::Item>, { sub_or_zero(N, SKIP) }>
[src]pub fn step_by<const STEP: usize>(
self
) -> IteratorFixed<impl Iterator<Item = I::Item>, { ceiling_div(N, STEP) }>
[src]
pub fn step_by<const STEP: usize>(
self
) -> IteratorFixed<impl Iterator<Item = I::Item>, { ceiling_div(N, STEP) }>
[src]pub fn chain<IIF, const M: usize>(
self,
other: IIF
) -> IteratorFixed<impl Iterator<Item = I::Item>, { N + M }> where
IIF: IntoIteratorFixed<M, Item = I::Item>,
[src]
pub fn chain<IIF, const M: usize>(
self,
other: IIF
) -> IteratorFixed<impl Iterator<Item = I::Item>, { N + M }> where
IIF: IntoIteratorFixed<M, Item = I::Item>,
[src]pub fn enumerate(
self
) -> IteratorFixed<impl Iterator<Item = (usize, I::Item)>, N>
[src]
pub fn enumerate(
self
) -> IteratorFixed<impl Iterator<Item = (usize, I::Item)>, N>
[src]pub fn take<const TAKE: usize>(
self
) -> IteratorFixed<impl Iterator<Item = I::Item>, { min(TAKE, N) }>
[src]
pub fn take<const TAKE: usize>(
self
) -> IteratorFixed<impl Iterator<Item = I::Item>, { min(TAKE, N) }>
[src]pub fn zip<IIF>(
self,
other: IIF
) -> IteratorFixed<impl Iterator<Item = (I::Item, IIF::Item)>, N> where
IIF: IntoIteratorFixed<N>,
[src]
pub fn zip<IIF>(
self,
other: IIF
) -> IteratorFixed<impl Iterator<Item = (I::Item, IIF::Item)>, N> where
IIF: IntoIteratorFixed<N>,
[src]pub fn rev(self) -> IteratorFixed<impl Iterator<Item = I::Item>, N> where
I: DoubleEndedIterator,
[src]
pub fn rev(self) -> IteratorFixed<impl Iterator<Item = I::Item>, N> where
I: DoubleEndedIterator,
[src]pub fn flatten<IIF, const M: usize>(
self
) -> IteratorFixed<impl Iterator<Item = IIF::Item>, { M * N }> where
I: Iterator<Item = IIF>,
IIF: IntoIteratorFixed<M>,
[src]
self
) -> IteratorFixed<impl Iterator<Item = IIF::Item>, { M * N }> where
I: Iterator<Item = IIF>,
IIF: IntoIteratorFixed<M>,
pub fn flat_map<F, IIF, const M: usize>(
self,
f: F
) -> IteratorFixed<impl Iterator<Item = IIF::Item>, { M * N }> where
F: FnMut(I::Item) -> IIF,
IIF: IntoIteratorFixed<M>,
[src]
self,
f: F
) -> IteratorFixed<impl Iterator<Item = IIF::Item>, { M * N }> where
F: FnMut(I::Item) -> IIF,
IIF: IntoIteratorFixed<M>,
pub fn collect<U: FromIteratorFixed<I, N>>(self) -> U
[src]
pub fn collect<U: FromIteratorFixed<I, N>>(self) -> U
[src]Transforms a fixed size iterator into a collection of compile time known size.
Basic usage:
use iter_fixed::IntoIteratorFixed; let two_four_six = [1, 2, 3].into_iter_fixed().map(|x| 2 * x); let a: [i32; 3] = two_four_six.collect(); assert_eq!(a, [2, 4, 6]);
impl<'a, I, T: 'a, const N: usize> IteratorFixed<I, N> where
I: Iterator<Item = &'a T>,
[src]
impl<'a, I, T: 'a, const N: usize> IteratorFixed<I, N> where
I: Iterator<Item = &'a T>,
[src]pub fn copied(self) -> IteratorFixed<impl Iterator<Item = T>, N> where
T: Copy,
[src]
pub fn copied(self) -> IteratorFixed<impl Iterator<Item = T>, N> where
T: Copy,
[src]pub fn cloned(self) -> IteratorFixed<impl Iterator<Item = T>, N> where
T: Clone,
[src]
pub fn cloned(self) -> IteratorFixed<impl Iterator<Item = T>, N> where
T: Clone,
[src]Trait Implementations
impl<T, I: Iterator<Item = T>, const N: usize> IntoIterator for IteratorFixed<I, N>
[src]
impl<T, I: Iterator<Item = T>, const N: usize> IntoIterator for IteratorFixed<I, N>
[src]Convert the fixed size iterator into an ordinary core::iter::Iterator
allowing it to be used with for loop syntax
fn into_iter(self) -> I
[src]
fn into_iter(self) -> I
[src]Convert the fixed size iterator into an ordinary core::iter::Iterator
impl<I: Iterator, const N: usize> IntoIteratorFixed<N> for IteratorFixed<I, N> where
IteratorFixed<I, N>: IntoIterator,
[src]
impl<I: Iterator, const N: usize> IntoIteratorFixed<N> for IteratorFixed<I, N> where
IteratorFixed<I, N>: IntoIterator,
[src]fn into_iter_fixed(self) -> IteratorFixed<Self::IntoIter, N>
[src]
fn into_iter_fixed(self) -> IteratorFixed<Self::IntoIter, N>
[src]IteratorFixed
implements IntoIteratorFixed
as a no op. This allows passing an
IteratorFixed
where an IntoIteratorFixed
was expected
Basic usage with zip which expects an IntoIteratorFixed as its argument:
use iter_fixed::IntoIteratorFixed; let one_one = [1, 1].into_iter_fixed(); let zipped: [_; 2] = [1, 2].into_iter_fixed().zip(one_one).collect(); assert_eq!(zipped, [(1, 1), (2, 1)]);
Auto Trait Implementations
impl<I, const N: usize> Send for IteratorFixed<I, N> where
I: Send,
I: Send,
impl<I, const N: usize> Sync for IteratorFixed<I, N> where
I: Sync,
I: Sync,
impl<I, const N: usize> Unpin for IteratorFixed<I, N> where
I: Unpin,
I: Unpin,