[][src]Enum pour::BinaryResult

pub enum BinaryResult<T> {
    New(T),
    Left,
    Right,
    Ambi,
}

A binary result, which can be either the left value, the right value, or a new value

Used to avoid cloning

Variants

New(T)

A new value

Left

The left value

Right

The right value

Ambi

Either the left or the right, don't care

Implementations

impl<T> BinaryResult<T>[src]

pub fn or_left(opt: Option<T>) -> BinaryResult<T>[src]

Convert an Option to a New or a Left

pub fn or_right(opt: Option<T>) -> BinaryResult<T>[src]

Convert an Option to a New or a Right

pub fn unwrap(self) -> T[src]

Unwrap a BinaryResult<T>, panicking if not New

pub fn unwrap_or_clone(self, left: &T, right: &T) -> T where
    T: Clone
[src]

Unwrap a BinaryResult<T>, cloning if not New

pub fn map<F, U>(self, func: F) -> BinaryResult<U> where
    F: FnOnce(T) -> U, 
[src]

Map a BinaryResult (as a functor)

pub fn swap_sides(self) -> BinaryResult<T>[src]

Swap the sides of a BinaryResult, i.e. flip Left and Right

Trait Implementations

impl<T: Clone> Clone for BinaryResult<T>[src]

impl<T: Copy> Copy for BinaryResult<T>[src]

impl<T: Debug> Debug for BinaryResult<T>[src]

impl<T: Eq> Eq for BinaryResult<T>[src]

impl<T: Hash> Hash for BinaryResult<T>[src]

impl<T: PartialEq> PartialEq<BinaryResult<T>> for BinaryResult<T>[src]

impl<T> StructuralEq for BinaryResult<T>[src]

impl<T> StructuralPartialEq for BinaryResult<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for BinaryResult<T> where
    T: RefUnwindSafe

impl<T> Send for BinaryResult<T> where
    T: Send

impl<T> Sync for BinaryResult<T> where
    T: Sync

impl<T> Unpin for BinaryResult<T> where
    T: Unpin

impl<T> UnwindSafe for BinaryResult<T> where
    T: UnwindSafe

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> CallHasher for T where
    T: Hash
[src]

impl<T> Erasable for T

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.