Skip to main content

SelectCombinator

Struct SelectCombinator 

Source
pub struct SelectCombinator<E, A, B> {
    pub lhs: OxiEither<A, E>,
    pub rhs: OxiEither<Box<dyn Fn(A) -> B>, E>,
}
Expand description

The select combinator for Either, implementing Selective behaviour.

select runs a computation that may short-circuit or choose between two branches. Given OxiEither<A, E> (lhs) and OxiEither<Box<dyn Fn(A) -> B>, E> (rhs), it applies the function when lhs is Left(a), otherwise short-circuits.

Fields§

§lhs: OxiEither<A, E>

The left-or-value argument.

§rhs: OxiEither<Box<dyn Fn(A) -> B>, E>

The function-or-error argument.

Implementations§

Source§

impl<E: Clone, A, B> SelectCombinator<E, A, B>

Source

pub fn new(lhs: OxiEither<A, E>, rhs: OxiEither<Box<dyn Fn(A) -> B>, E>) -> Self

Construct a new select combinator.

Source

pub fn select(self) -> OxiEither<B, E>

Run the select combinator, returning OxiEither<B, E>.

Source

pub fn select_right_law(e: E) -> OxiEither<B, E>

Witness of: select (Right e) _ = Right e

Auto Trait Implementations§

§

impl<E, A, B> Freeze for SelectCombinator<E, A, B>
where A: Freeze, E: Freeze,

§

impl<E, A, B> !RefUnwindSafe for SelectCombinator<E, A, B>

§

impl<E, A, B> !Send for SelectCombinator<E, A, B>

§

impl<E, A, B> !Sync for SelectCombinator<E, A, B>

§

impl<E, A, B> Unpin for SelectCombinator<E, A, B>
where A: Unpin, E: Unpin,

§

impl<E, A, B> UnsafeUnpin for SelectCombinator<E, A, B>
where A: UnsafeUnpin, E: UnsafeUnpin,

§

impl<E, A, B> !UnwindSafe for SelectCombinator<E, A, B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.