A type that represents one of two alternatives

Enum either

The either type

Variants

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

pure fn flip<T: copy, U: copy>(eith: either<T, U>) -> either<U, T>

Flips between left and right of a given either

Function is_left

pure fn is_left<T, U>(eith: either<T, U>) -> bool

Checks whether the given value is a left

Function is_right

pure 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: copy, U: copy>(eithers: ~[either<T, U>]) ->
   {lefts: ~[T], rights: ~[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

pure fn to_result<T: copy, U: copy>(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