NEEither

Enum NEEither 

Source
pub enum NEEither<L, R> {
    Left(L),
    Right(R),
}
Expand description

Non-empty variant of either::Either that implements NonEmptyIterator.

Variants§

§

Left(L)

A value of type L.

§

Right(R)

A value of type R.

Implementations§

Source§

impl<L, R> NEEither<L, R>

Source

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: Clone, R: Clone> Clone for NEEither<L, R>

Source§

fn clone(&self) -> NEEither<L, R>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<L: Debug, R: Debug> Debug for NEEither<L, R>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<L: Hash, R: Hash> Hash for NEEither<L, R>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<L, R> IntoIterator for NEEither<L, R>
where L: IntoIterator, R: IntoIterator<Item = L::Item>,

Source§

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>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<L, R> NonEmptyIterator for NEEither<L, R>

Source§

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 peekable(self) -> Peekable<Self::IntoIter>
where Self: Sized,

Creates an iterator which can use the peek and peek_mut methods to look at the next element of the iterator without consuming it. See their documentation for more information. Read more
Source§

fn all<F>(self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> bool,

Tests if every element of the iterator matches a predicate. Read more
Source§

fn any<F>(self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> 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>
where Self: Sized, U: IntoIterator<Item = Self::Item>,

Takes two iterators and creates a new non-empty iterator over both in sequence. Read more
Source§

fn cloned<'a, T>(self) -> Cloned<Self>
where Self: Sized + NonEmptyIterator<Item = &'a T>, T: Clone + 'a,

Creates a non-empty iterator which clones all of its elements. Read more
Source§

fn collect<B>(self) -> B
where Self: Sized, B: FromNonEmptyIterator<Self::Item>,

Transforms an iterator into a collection, or some other concrete value. Read more
Source§

fn copied<'a, T>(self) -> Copied<Self::IntoIter>
where Self: Sized + NonEmptyIterator<Item = &'a T>, T: Copy + 'a,

Creates a non-empty iterator which copies all of its elements. Read more
Source§

fn count(self) -> NonZeroUsize
where 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,

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>
where Self: Sized, P: FnMut(&<Self as IntoIterator>::Item) -> bool,

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>
where Self: Sized, F: FnMut(<Self as IntoIterator>::Item) -> Option<B>,

Creates an iterator that both filters and maps. Read more
Source§

fn find<P>(self, predicate: P) -> Option<Self::Item>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

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>
where Self: Sized, F: FnMut(Self::Item) -> U, U: IntoNonEmptyIterator,

Creates an iterator that works like map, but flattens nested, non-empty structure. Read more
Source§

fn fold<B, F>(self, init: B, f: F) -> B
where Self: Sized, F: FnMut(B, Self::Item) -> 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>
where Self: Sized, F: FnMut(&Self::Item) -> K, K: PartialEq,

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 more
Source§

fn intersperse(self, item: Self::Item) -> Intersperse<Self>
where Self: Sized, Self::Item: Clone,

Inject a given value between each item of the NonEmptyIterator. Read more
Source§

fn map<U, F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> U,

Takes a closure and creates a non-empty iterator which calls that closure on each element. Read more
Source§

fn max(self) -> Self::Item
where Self: Sized, Self::Item: Ord,

Returns the maximum element of a non-empty iterator. Read more
Source§

fn max_by<F>(self, compare: F) -> Self::Item
where Self: Sized, F: Fn(&Self::Item, &Self::Item) -> Ordering,

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
where Self: Sized, B: Ord, F: FnMut(&Self::Item) -> B,

Returns the element that gives the maximum value from the specified function. Read more
Source§

fn min(self) -> Self::Item
where Self: Sized, Self::Item: Ord,

Returns the minimum element of a non-empty iterator. Read more
Source§

fn min_by<F>(self, compare: F) -> Self::Item
where Self: Sized, F: Fn(&Self::Item, &Self::Item) -> Ordering,

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
where Self: Sized, B: Ord, F: FnMut(&Self::Item) -> B,

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>
where Self: Sized, K: Ord, F: FnMut(&Self::Item) -> K,

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,

Returns the nth element of the iterator. Read more
Source§

fn skip(self, n: usize) -> Skip<<Self as IntoIterator>::IntoIter>
where Self: Sized,

Skip the first n elements. Read more
Source§

fn skip_while<P>( self, pred: P, ) -> SkipWhile<<Self as IntoIterator>::IntoIter, P>
where Self: Sized, P: FnMut(&<Self as IntoIterator>::Item) -> bool,

Skips over all initial elements that pass a given predicate. Read more
Source§

fn sum<S>(self) -> S
where Self: Sized + IntoIterator, S: Sum<<Self as IntoIterator>::Item>,

Sums the elements of a non-empty iterator. Read more
Source§

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 more
Source§

fn take_while<P>( self, pred: P, ) -> TakeWhile<<Self as IntoIterator>::IntoIter, P>
where Self: Sized, P: FnMut(&<Self as IntoIterator>::Item) -> bool,

Iterates over all initial elements that pass a given predicate. Read more
Source§

fn product<P>(self) -> P
where Self: Sized + IntoIterator, P: Product<<Self as IntoIterator>::Item>,

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,

“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)
where FromA: Singleton<Item = A> + Extend<A>, FromB: Singleton<Item = B> + Extend<B>, Self: Sized + NonEmptyIterator<Item = (A, B)>,

Reduce a non-empty iterator of pairs into a pair of concrete containers. Read more
Source§

fn reduce<F>(self, f: F) -> Self::Item
where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item,

Reduces the elements to a single one, by repeatedly applying a reducing operation. Read more
Source§

impl<L: Ord, R: Ord> Ord for NEEither<L, R>

Source§

fn cmp(&self, other: &NEEither<L, R>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<L: PartialEq, R: PartialEq> PartialEq for NEEither<L, R>

Source§

fn eq(&self, other: &NEEither<L, R>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<L: PartialOrd, R: PartialOrd> PartialOrd for NEEither<L, R>

Source§

fn partial_cmp(&self, other: &NEEither<L, R>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<L: Copy, R: Copy> Copy for NEEither<L, R>

Source§

impl<L: Eq, R: Eq> Eq for NEEither<L, R>

Source§

impl<L, R> StructuralPartialEq for NEEither<L, R>

Auto Trait Implementations§

§

impl<L, R> Freeze for NEEither<L, R>
where L: Freeze, R: Freeze,

§

impl<L, R> RefUnwindSafe for NEEither<L, R>

§

impl<L, R> Send for NEEither<L, R>
where L: Send, R: Send,

§

impl<L, R> Sync for NEEither<L, R>
where L: Sync, R: Sync,

§

impl<L, R> Unpin for NEEither<L, R>
where L: Unpin, R: Unpin,

§

impl<L, R> UnwindSafe for NEEither<L, R>
where L: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> IntoIteratorExt for T
where T: IntoIterator,

Source§

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

The type of the elements being iterated over.
Source§

type IntoIter = NonEmptyIterAdapter<Peekable<<T as IntoIterator>::IntoIter>>

Which kind of NonEmptyIterator are we turning this into?
Source§

impl<I> IntoNonEmptyIterator for I

Source§

type IntoNEIter = I

Which kind of NonEmptyIterator are we turning this into?
Source§

fn into_nonempty_iter(self) -> <I as IntoNonEmptyIterator>::IntoNEIter

Creates a NonEmptyIterator from a value.
Source§

impl<T> NonEmptyItertools for T
where T: NonEmptyIterator + ?Sized,

Source§

fn cartesian_product<J>(self, other: J) -> Product<Self, J::IntoNEIter>

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
Source§

fn all_unique(self) -> bool
where Self: Sized, Self::Item: Eq + Hash,

Check whether all elements are unique (non equal). Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.