Enum itertools::EitherOrBoth [−][src]
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 values are present.
Only the left value of type A
is present.
Only the right value of type B
is present.
Implementations
impl<A, B> EitherOrBoth<A, B>
[src]
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]
F: FnOnce(A) -> M,
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]
F: FnOnce(B) -> M,
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]
F: FnOnce(A) -> L,
G: FnOnce(B) -> R,
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]
F: FnOnce(A) -> EitherOrBoth<L, B>,
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]
F: FnOnce(B) -> EitherOrBoth<A, R>,
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]
impl<T> EitherOrBoth<T, T>
[src]Trait Implementations
impl<A: Clone, B: Clone> Clone for EitherOrBoth<A, B>
[src]
impl<A: Clone, B: Clone> Clone for EitherOrBoth<A, B>
[src]fn clone(&self) -> EitherOrBoth<A, B>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<A: Debug, B: Debug> Debug for EitherOrBoth<A, B>
[src]
impl<A: Debug, B: Debug> Debug for EitherOrBoth<A, B>
[src]impl<A: Hash, B: Hash> Hash for EitherOrBoth<A, B>
[src]
impl<A: Hash, B: Hash> Hash for EitherOrBoth<A, B>
[src]impl<A, B> Into<Option<Either<A, B>>> 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: PartialEq, B: PartialEq> PartialEq<EitherOrBoth<A, B>> for EitherOrBoth<A, B>
[src]fn eq(&self, other: &EitherOrBoth<A, B>) -> bool
[src]
fn ne(&self, other: &EitherOrBoth<A, B>) -> bool
[src]
impl<A: Eq, B: Eq> Eq 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> RefUnwindSafe for EitherOrBoth<A, B> where
A: RefUnwindSafe,
B: RefUnwindSafe,
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for EitherOrBoth<A, B> where
A: Send,
B: Send,
A: Send,
B: Send,
impl<A, B> Sync for EitherOrBoth<A, B> where
A: Sync,
B: Sync,
A: Sync,
B: Sync,
impl<A, B> Unpin for EitherOrBoth<A, B> where
A: Unpin,
B: Unpin,
A: Unpin,
B: Unpin,
impl<A, B> UnwindSafe for EitherOrBoth<A, B> where
A: UnwindSafe,
B: UnwindSafe,
A: UnwindSafe,
B: UnwindSafe,