pub struct ArrayNonEmptyIterator<T, const C: usize> { /* private fields */ }
Expand description
Non-empty iterator for arrays with length > 0.
§Examples
Use non-zero length arrays anywhere an IntoNonEmptyIterator
is expected.
use std::num::NonZeroUsize;
use nonempty_collections::*;
fn is_one<T>(iter: impl IntoNonEmptyIterator<Item = T>) {
assert_eq!(NonZeroUsize::MIN, iter.into_nonempty_iter().count());
}
is_one([0]);
Only compiles for non-empty arrays:
ⓘ
use nonempty_collections::*;
fn is_one(iter: impl IntoNonEmptyIterator<Item = usize>) {}
is_one([]); // Doesn't compile because it is empty.
Trait Implementations§
Source§impl<T: Clone, const C: usize> Clone for ArrayNonEmptyIterator<T, C>
impl<T: Clone, const C: usize> Clone for ArrayNonEmptyIterator<T, C>
Source§fn clone(&self) -> ArrayNonEmptyIterator<T, C>
fn clone(&self) -> ArrayNonEmptyIterator<T, C>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T, const C: usize> IntoIterator for ArrayNonEmptyIterator<T, C>
impl<T, const C: usize> IntoIterator for ArrayNonEmptyIterator<T, C>
Source§impl<T, const C: usize> NonEmptyIterator for ArrayNonEmptyIterator<T, C>
impl<T, const C: usize> NonEmptyIterator for ArrayNonEmptyIterator<T, C>
Source§fn next(self) -> (Self::Item, Self::IntoIter)where
Self: Sized,
fn next(self) -> (Self::Item, Self::IntoIter)where
Self: Sized,
Advances this non-empty iterator, consuming its ownership. Yields the
first item and a possibly empty iterator containing the rest of the
elements.
Source§fn all<F>(self, f: F) -> bool
fn all<F>(self, f: F) -> bool
Tests if every element of the iterator matches a predicate. Read more
Source§fn any<F>(self, f: F) -> bool
fn any<F>(self, f: F) -> bool
Tests if any element of the iterator matches a predicate. Read more
Source§fn chain<U>(self, other: U) -> Chain<Self::IntoIter, U::IntoIter>
fn chain<U>(self, other: U) -> Chain<Self::IntoIter, U::IntoIter>
Takes two iterators and creates a new non-empty iterator over both in
sequence. Read more
Source§fn cloned<'a, T>(self) -> Cloned<Self>
fn cloned<'a, T>(self) -> Cloned<Self>
Creates a non-empty iterator which clones all of its elements. Read more
Source§fn collect<B>(self) -> B
fn collect<B>(self) -> B
Transforms an iterator into a collection, or some other concrete value. Read more
Source§fn copied<'a, T>(self) -> Copied<Self::IntoIter>
fn copied<'a, T>(self) -> Copied<Self::IntoIter>
Creates a non-empty iterator which copies all of its elements. Read more
Source§fn count(self) -> NonZeroUsizewhere
Self: Sized,
fn count(self) -> NonZeroUsizewhere
Self: Sized,
Consumes the non-empty iterator, counting the number of iterations and
returning it. Read more
Source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
Creates a non-empty iterator which gives the current iteration count as
well as the next value. Read more
Source§fn filter<P>(self, predicate: P) -> Filter<<Self as IntoIterator>::IntoIter, P>
fn filter<P>(self, predicate: P) -> Filter<<Self as IntoIterator>::IntoIter, P>
Creates an iterator which uses a closure to determine if an element
should be yielded. Read more
Source§fn filter_map<B, F>(
self,
f: F,
) -> FilterMap<<Self as IntoIterator>::IntoIter, F>
fn filter_map<B, F>( self, f: F, ) -> FilterMap<<Self as IntoIterator>::IntoIter, F>
Creates an iterator that both filters and maps. Read more
Source§fn find<P>(self, predicate: P) -> Option<Self::Item>
fn find<P>(self, predicate: P) -> Option<Self::Item>
Searches for an element of an iterator that satisfies a predicate. Read more
Source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self::IntoIter, U, F>
fn flat_map<U, F>(self, f: F) -> FlatMap<Self::IntoIter, U, F>
Creates an iterator that works like
map
, but flattens nested,
non-empty structure. Read moreSource§fn fold<B, F>(self, init: B, f: F) -> B
fn fold<B, F>(self, init: B, f: F) -> B
Folds every element into an accumulator by applying an operation,
returning the final result. Read more
Source§fn group_by<K, F>(self, f: F) -> NEGroupBy<Self, F>
fn group_by<K, F>(self, f: F) -> NEGroupBy<Self, F>
Group the non-empty input stream into concrete, non-empty subsections
via a given function. The cutoff criterion is whether the return value
of
f
changes between two consecutive elements. Read moreSource§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
Takes a closure and creates a non-empty iterator which calls that
closure on each element. Read more
Source§fn max_by<F>(self, compare: F) -> Self::Item
fn max_by<F>(self, compare: F) -> Self::Item
Returns the element that gives the maximum value with respect to the
given comparison function. Read more
Source§fn max_by_key<B, F>(self, key: F) -> Self::Item
fn max_by_key<B, F>(self, key: F) -> Self::Item
Returns the element that gives the maximum value from the
specified function. Read more
Source§fn min_by<F>(self, compare: F) -> Self::Item
fn min_by<F>(self, compare: F) -> Self::Item
Returns the element that gives the minimum value with respect to the
given comparison function. Read more
Source§fn min_by_key<B, F>(self, key: F) -> Self::Item
fn min_by_key<B, F>(self, key: F) -> Self::Item
Returns the element that gives the minimum value from the
specified function. Read more
Source§fn sorted_by_key<K, F>(self, f: F) -> IntoIter<Self::Item>
fn sorted_by_key<K, F>(self, f: F) -> IntoIter<Self::Item>
Sort all iterator elements into a new non-empty iterator in ascending
order. Read more
Source§fn nth(self, n: usize) -> Option<Self::Item>where
Self: Sized,
fn nth(self, n: usize) -> Option<Self::Item>where
Self: Sized,
Returns the
n
th element of the iterator. Read moreSource§fn skip(self, n: usize) -> Skip<<Self as IntoIterator>::IntoIter>where
Self: Sized,
fn skip(self, n: usize) -> Skip<<Self as IntoIterator>::IntoIter>where
Self: Sized,
Skip the first
n
elements. Read moreSource§fn skip_while<P>(
self,
pred: P,
) -> SkipWhile<<Self as IntoIterator>::IntoIter, P>
fn skip_while<P>( self, pred: P, ) -> SkipWhile<<Self as IntoIterator>::IntoIter, P>
Skips over all initial elements that pass a given predicate. Read more
Source§fn take(self, n: NonZeroUsize) -> Take<Self>where
Self: Sized,
fn take(self, n: NonZeroUsize) -> Take<Self>where
Self: Sized,
Iterates over the first
n
elements, or fewer if the underlying
iterator ends sooner. Read moreSource§fn take_while<P>(
self,
pred: P,
) -> TakeWhile<<Self as IntoIterator>::IntoIter, P>
fn take_while<P>( self, pred: P, ) -> TakeWhile<<Self as IntoIterator>::IntoIter, P>
Iterates over all initial elements that pass a given predicate. Read more
Source§fn product<P>(self) -> P
fn product<P>(self) -> P
Iterates over the entire non-empty iterator, multiplying all the
elements. Read more
Auto Trait Implementations§
impl<T, const C: usize> Freeze for ArrayNonEmptyIterator<T, C>where
T: Freeze,
impl<T, const C: usize> RefUnwindSafe for ArrayNonEmptyIterator<T, C>where
T: RefUnwindSafe,
impl<T, const C: usize> Send for ArrayNonEmptyIterator<T, C>where
T: Send,
impl<T, const C: usize> Sync for ArrayNonEmptyIterator<T, C>where
T: Sync,
impl<T, const C: usize> Unpin for ArrayNonEmptyIterator<T, C>where
T: Unpin,
impl<T, const C: usize> UnwindSafe for ArrayNonEmptyIterator<T, C>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoIteratorExt for Twhere
T: IntoIterator,
impl<T> IntoIteratorExt for Twhere
T: IntoIterator,
Source§fn try_into_nonempty_iter(self) -> Option<<T as IntoIteratorExt>::IntoIter>
fn try_into_nonempty_iter(self) -> Option<<T as IntoIteratorExt>::IntoIter>
Converts self
into a non-empty iterator or returns None
if
the iterator is empty.
Source§type Item = <T as IntoIterator>::Item
type Item = <T as IntoIterator>::Item
The type of the elements being iterated over.
Source§type IntoIter = NonEmptyIterAdapter<Peekable<<T as IntoIterator>::IntoIter>>
type IntoIter = NonEmptyIterAdapter<Peekable<<T as IntoIterator>::IntoIter>>
Which kind of
NonEmptyIterator
are we turning this into?Source§impl<I> IntoNonEmptyIterator for Iwhere
I: NonEmptyIterator,
impl<I> IntoNonEmptyIterator for Iwhere
I: NonEmptyIterator,
Source§type IntoNEIter = I
type IntoNEIter = I
Which kind of
NonEmptyIterator
are we turning this into?Source§fn into_nonempty_iter(self) -> <I as IntoNonEmptyIterator>::IntoNEIter
fn into_nonempty_iter(self) -> <I as IntoNonEmptyIterator>::IntoNEIter
Creates a
NonEmptyIterator
from a value.Source§impl<T> NonEmptyItertools for Twhere
T: NonEmptyIterator + ?Sized,
impl<T> NonEmptyItertools for Twhere
T: NonEmptyIterator + ?Sized,
Source§fn cartesian_product<J>(self, other: J) -> Product<Self, J::IntoNEIter>where
Self: Sized,
Self::Item: Clone,
J: IntoNonEmptyIterator,
<J::IntoNEIter as IntoIterator>::IntoIter: Clone,
fn cartesian_product<J>(self, other: J) -> Product<Self, J::IntoNEIter>where
Self: Sized,
Self::Item: Clone,
J: IntoNonEmptyIterator,
<J::IntoNEIter as IntoIterator>::IntoIter: Clone,
Return a non-empty iterator adaptor that iterates over the non-empty
cartesian product of the element sets of two iterators
self
and
J
. Read more