pub enum NEEither<L, R> {
Left(L),
Right(R),
}Expand description
Non-empty variant of either::Either that implements
NonEmptyIterator.
Variants§
Implementations§
Source§impl<L, R> NEEither<L, R>
impl<L, R> NEEither<L, R>
Sourcepub fn into_nonempty_iter(self) -> NEEither<L::IntoNEIter, R::IntoNEIter>
pub fn into_nonempty_iter(self) -> NEEither<L::IntoNEIter, R::IntoNEIter>
Convert the inner value to a NonEmptyIterator.
This requires the Left and Right non-empty iterators to have the
same item type.
use nonempty_collections::*;
let left: NEEither<_, NESet<usize>> = NEEither::Left(nev![1, 2, 3]);
let right: NEEither<NEVec<usize>, _> = NEEither::Right(nes![4]);
let combined = left.into_nonempty_iter().chain(right).collect::<NEVec<_>>();
let expected = nev![1, 2, 3, 4];
assert_eq!(expected, combined);Trait Implementations§
Source§impl<L, R> IntoIterator for NEEither<L, R>
impl<L, R> IntoIterator for NEEither<L, R>
Source§type Item = <L as IntoIterator>::Item
type Item = <L as IntoIterator>::Item
The type of the elements being iterated over.
Source§type IntoIter = Either<<L as IntoIterator>::IntoIter, <R as IntoIterator>::IntoIter>
type IntoIter = Either<<L as IntoIterator>::IntoIter, <R as IntoIterator>::IntoIter>
Which kind of iterator are we turning this into?
Source§impl<L, R> NonEmptyIterator for NEEither<L, R>
impl<L, R> NonEmptyIterator for NEEither<L, R>
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 intersperse(self, item: Self::Item) -> Intersperse<Self>
fn intersperse(self, item: Self::Item) -> Intersperse<Self>
Inject a given value between each item of the
NonEmptyIterator. 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
nth 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
Source§fn zip<U>(self, other: U) -> Zip<Self::IntoIter, U::IntoIter>where
Self: Sized,
U: IntoNonEmptyIterator,
fn zip<U>(self, other: U) -> Zip<Self::IntoIter, U::IntoIter>where
Self: Sized,
U: IntoNonEmptyIterator,
“Zips up” two non-empty iterators into a single one, while preserving
non-emptiness. Read more
Source§fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
Reduce a non-empty iterator of pairs into a pair of concrete containers. Read more
Source§impl<L: Ord, R: Ord> Ord for NEEither<L, R>
impl<L: Ord, R: Ord> Ord for NEEither<L, R>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<L: PartialOrd, R: PartialOrd> PartialOrd for NEEither<L, R>
impl<L: PartialOrd, R: PartialOrd> PartialOrd for NEEither<L, R>
impl<L: Copy, R: Copy> Copy for NEEither<L, R>
impl<L: Eq, R: Eq> Eq for NEEither<L, R>
impl<L, R> StructuralPartialEq for NEEither<L, R>
Auto Trait Implementations§
impl<L, R> Freeze for NEEither<L, R>
impl<L, R> RefUnwindSafe for NEEither<L, R>where
L: RefUnwindSafe,
R: RefUnwindSafe,
impl<L, R> Send for NEEither<L, R>
impl<L, R> Sync for NEEither<L, R>
impl<L, R> Unpin for NEEither<L, R>
impl<L, R> UnwindSafe for NEEither<L, R>where
L: UnwindSafe,
R: 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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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