A type that represents one of two alternatives

Enum Either

The either type

Variants

Implementation of ::std::clone::Clone for Either<T, U> where <T: ::std::clone::Clone, U: ::std::clone::Clone>

Automatically derived.

Method clone

fn clone(&self) -> Either<T, U>

Implementation of ::std::cmp::Eq for Either<T, U> where <T: ::std::cmp::Eq, U: ::std::cmp::Eq>

Automatically derived.

Method eq

fn eq(&self, __arg_0: &Either<T, U>) -> ::bool

Method ne

fn ne(&self, __arg_0: &Either<T, U>) -> ::bool

Implementation for Either<T, U> where <T, U>

Method either

fn either<V>(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V

Method flip

fn flip(self) -> Either<U, T>

Method to_result

fn to_result(self) -> Result<U, T>

Method is_left

fn is_left(&self) -> bool

Method is_right

fn is_right(&self) -> bool

Method unwrap_left

fn unwrap_left(self) -> T

Method unwrap_right

fn unwrap_right(self) -> U

Function either

fn either<T, U,
          V>(f_left: &fn(&T) -> V, f_right: &fn(&U) -> V,
             value: &Either<T, U>) -> V

Applies a function based on the given either value

If value is left(T) then f_left is applied to its contents, if value is right(U) then f_right is applied to its contents, and the result is returned.

Function flip

fn flip<T, U>(eith: Either<T, U>) -> Either<U, T>

Flips between left and right of a given either

Function is_left

fn is_left<T, U>(eith: &Either<T, U>) -> bool

Checks whether the given value is a left

Function is_right

fn is_right<T, U>(eith: &Either<T, U>) -> bool

Checks whether the given value is a right

Function lefts

fn lefts<T: Copy, U>(eithers: &[Either<T, U>]) -> ~[T]

Extracts from a vector of either all the left values

Function partition

fn partition<T, U>(eithers: ~[Either<T, U>]) -> (~[T], ~[U])

Extracts from a vector of either all the left values and right values

Returns a structure containing a vector of left values and a vector of right values.

Function rights

fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U]

Extracts from a vector of either all the right values

Function to_result

fn to_result<T, U>(eith: Either<T, U>) -> Result<U, T>

Converts either::t to a result::t

Converts an either type to a result type, making the "right" choice an ok result, and the "left" choice a fail

Function unwrap_left

fn unwrap_left<T, U>(eith: Either<T, U>) -> T

Retrieves the value in the left branch. Fails if the either is Right.

Function unwrap_right

fn unwrap_right<T, U>(eith: Either<T, U>) -> U

Retrieves the value in the right branch. Fails if the either is Left.