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

Both(A, B)
Expand description

Both values are present.

Left(A)
Expand description

Only the left value of type A is present.

Right(B)
Expand description

Only the right value of type B is present.

Implementations

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, B> Clone for EitherOrBoth<A, B> where
    A: Clone,
    B: Clone
[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]

Performs copy-assignment from source. Read more

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

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

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

pub fn hash<__H>(&self, state: &mut __H) where
    __H: Hasher
[src]

Feeds this value into the given Hasher. Read more

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

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

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

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

Performs the conversion.

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]

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]

This method tests for !=.

impl<A, B> Eq for EitherOrBoth<A, B> where
    A: Eq,
    B: Eq
[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

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

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

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[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]

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]

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]

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]

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]

pub fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + 'static + Sync + Send>[src]

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

impl<T> DynClone for T where
    T: Clone
[src]

pub fn __clone_box(&self, Private) -> *mut ()[src]

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

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.

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

Performs the conversion.

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.

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

Performs the conversion.