[][src]Trait mini_haskell::utils::control::Either

pub trait Either {
    type Left;
    type Right;
    fn left(x: Self::Left) -> Self;
fn right(x: Self::Right) -> Self;
fn into_result(self) -> Result<Self::Right, Self::Left>; }

The std::ops::Try trait is not yet stable. We roll up our own for now. It is named after Either, Left, and Right from Haskell.

Associated Types

type Left

The type to propagate in a Left.

type Right

The type to continue with in a Right.

Loading content...

Required methods

fn left(x: Self::Left) -> Self

Construct a Left:

fn right(x: Self::Right) -> Self

Construct a Right:

fn into_result(self) -> Result<Self::Right, Self::Left>

Consumes the value and makes a Result.

Note that by design (to follow the convention in Haskell), the Err is for Left and the Ok is for Right.

Loading content...

Implementations on Foreign Types

impl<T> Either for Option<T>[src]

type Left = Option<Void>

type Right = T

impl<T, E> Either for Result<T, E>[src]

type Left = E

type Right = T

Loading content...

Implementors

impl<T, E, M> Either for Result3<T, E, M>[src]

type Left = M

type Right = Result3<T, E, Void>

Loading content...