[][src]Enum itertools::EitherOrBoth

pub enum EitherOrBoth<A, B> {
    Both(A, B),
    Left(A),
    Right(B),
}

Value that either holds a single A or B, or both.

Variants

Both(A, B)

Both values are present.

Left(A)

Only the left value of type A is present.

Right(B)

Only the right value of type B is present.

Methods

impl<A, B> EitherOrBoth<A, B>[src]

pub fn has_left(&self) -> bool[src]

If Left, or Both, return true, otherwise, return false.

pub fn has_right(&self) -> bool[src]

If Right, or Both, return true, otherwise, return false.

pub fn is_left(&self) -> bool[src]

If Left, return true otherwise, return false. Exclusive version of [has_left].

pub fn is_right(&self) -> bool[src]

If Right, return true otherwise, return false. Exclusive version of [has_right].

pub fn is_both(&self) -> bool[src]

If Right, return true otherwise, return false. Equivalent to self.as_ref().both().is_some().

pub fn left(self) -> Option<A>[src]

If Left, or Both, return Some with the left value, otherwise, return None.

pub fn right(self) -> Option<B>[src]

If Right, or Both, return Some with the right value, otherwise, return None.

pub fn both(self) -> Option<(A, B)>[src]

If Both, return Some tuple containing left and right.

pub fn as_ref(&self) -> EitherOrBoth<&A, &B>[src]

Converts from &EitherOrBoth<A, B> to EitherOrBoth<&A, &B>.

pub fn as_mut(&mut self) -> EitherOrBoth<&mut A, &mut B>[src]

Converts from &mut EitherOrBoth<A, B> to EitherOrBoth<&mut A, &mut B>.

pub fn flip(self) -> EitherOrBoth<B, A>[src]

Convert EitherOrBoth<A, B> to EitherOrBoth<B, A>.

pub fn map_left<F, M>(self, f: F) -> EitherOrBoth<M, B> where
    F: FnOnce(A) -> M, 
[src]

Apply the function f on the value a in Left(a) or Both(a, b) variants. If it is present rewrapping the result in self's original variant.

pub fn map_right<F, M>(self, f: F) -> EitherOrBoth<A, M> where
    F: FnOnce(B) -> M, 
[src]

Apply the function f on the value b in Right(b) or Both(a, b) variants. If it is present rewrapping the result in self's original variant.

pub fn map_any<F, L, G, R>(self, f: F, g: G) -> EitherOrBoth<L, R> where
    F: FnOnce(A) -> L,
    G: FnOnce(B) -> R, 
[src]

Apply the functions f and g on the value a and b respectively; found in Left(a), Right(b), or Both(a, b) variants. The Result is rewrapped self's original variant.

pub fn left_and_then<F, L>(self, f: F) -> EitherOrBoth<L, B> where
    F: FnOnce(A) -> EitherOrBoth<L, B>, 
[src]

Apply the function f on the value b in Right(b) or Both(a, _) variants if it is present.

pub fn right_and_then<F, R>(self, f: F) -> EitherOrBoth<A, R> where
    F: FnOnce(B) -> EitherOrBoth<A, R>, 
[src]

Apply the function f on the value a in Left(a) or Both(a, _) variants if it is present.

impl<T> EitherOrBoth<T, T>[src]

pub fn reduce<F>(self, f: F) -> T where
    F: FnOnce(T, T) -> T, 
[src]

Return either value of left, right, or the product of f applied where Both are present.

Trait Implementations

impl<A: Clone, B: Clone> Clone for EitherOrBoth<A, B>[src]

impl<A: Debug, B: Debug> Debug for EitherOrBoth<A, B>[src]

impl<A: Eq, B: Eq> Eq for EitherOrBoth<A, B>[src]

impl<A, B> Into<Option<Either<A, B>>> for EitherOrBoth<A, B>[src]

impl<A: PartialEq, B: PartialEq> PartialEq<EitherOrBoth<A, B>> for EitherOrBoth<A, B>[src]

impl<A, B> StructuralEq for EitherOrBoth<A, B>[src]

impl<A, B> StructuralPartialEq for EitherOrBoth<A, B>[src]

Auto Trait Implementations

impl<A, B> Send for EitherOrBoth<A, B> where
    A: Send,
    B: Send

impl<A, B> Sync for EitherOrBoth<A, B> where
    A: Sync,
    B: Sync

impl<A, B> Unpin for EitherOrBoth<A, B> where
    A: Unpin,
    B: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.