Enum tract_core::internal::tract_itertools::EitherOrBoth [−][src]
pub enum EitherOrBoth<A, B> { Both(A, B), Left(A), Right(B), }
Expand description
Value that either holds a single A or B, or both.
Variants
Expand description
Both values are present.
Expand description
Only the left value of type A
is present.
Expand description
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 is_left(&self) -> bool
[src]
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]
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]
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]
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]
pub fn right(self) -> Option<B>
[src]If Right
, or Both
, return Some
with the right value, otherwise, return None
.
pub fn as_ref(&self) -> EitherOrBoth<&A, &B>
[src]
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]
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]
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]
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]
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]
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]
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]
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]
impl<T> EitherOrBoth<T, T>
[src]Trait Implementations
impl<A, B> Clone for EitherOrBoth<A, B> where
A: Clone,
B: Clone,
[src]
impl<A, B> Clone for EitherOrBoth<A, B> where
A: Clone,
B: Clone,
[src]pub fn clone(&self) -> EitherOrBoth<A, B>
[src]
pub fn clone(&self) -> EitherOrBoth<A, B>
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl<A, B> Debug for EitherOrBoth<A, B> where
A: Debug,
B: Debug,
[src]
impl<A, B> Debug for EitherOrBoth<A, B> where
A: Debug,
B: Debug,
[src]impl<A, B> Hash for EitherOrBoth<A, B> where
A: Hash,
B: Hash,
[src]
impl<A, B> Hash for EitherOrBoth<A, B> where
A: Hash,
B: Hash,
[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, B> PartialEq<EitherOrBoth<A, B>> for EitherOrBoth<A, B> where
A: PartialEq<A>,
B: PartialEq<B>,
[src]
impl<A, B> PartialEq<EitherOrBoth<A, B>> for EitherOrBoth<A, B> where
A: PartialEq<A>,
B: PartialEq<B>,
[src]pub fn eq(&self, other: &EitherOrBoth<A, B>) -> bool
[src]
pub fn eq(&self, other: &EitherOrBoth<A, B>) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
pub fn ne(&self, other: &EitherOrBoth<A, B>) -> bool
[src]
pub fn ne(&self, other: &EitherOrBoth<A, B>) -> bool
[src]This method tests for !=
.
impl<A, B> Eq for EitherOrBoth<A, B> where
A: Eq,
B: Eq,
[src]
A: Eq,
B: Eq,
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,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
[src]
impl<T> Downcast for T where
T: Any,
[src]pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn as_any(&self) -> &(dyn Any + 'static)
[src]
pub fn as_any(&self) -> &(dyn Any + 'static)
[src]Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
impl<T> DowncastSync for T where
T: Any + Send + Sync,
[src]
impl<T> DowncastSync for T where
T: Any + Send + Sync,
[src]impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more