A type that represents one of two alternatives
Either
- The either typeof ::std::clone::Clone for Either<T, U> where <T: ::std::clone::Clone, U: ::std::clone::Clone>
- Automatically derived.of ::std::cmp::Eq for Either<T, U> where <T: ::std::cmp::Eq, U: ::std::cmp::Eq>
- Automatically derived.for Either<T, U> where <T, U>
either
- Applies a function based on the given either valueflip
- Flips between left and right of a given eitheris_left
- Checks whether the given value is a leftis_right
- Checks whether the given value is a rightlefts
- Extracts from a vector of either all the left valuespartition
- Extracts from a vector of either all the left values and right valuesrights
- Extracts from a vector of either all the right valuesto_result
- Converts either::t to a result::tunwrap_left
- Retrieves the value in the left branchunwrap_right
- Retrieves the value in the right branchEither
The either type
Left(T)
Right(U)
::std::clone::Clone
for Either<T, U>
where <T: ::std::clone::Clone, U: ::std::clone::Clone>
Automatically derived.
clone
fn clone(&self) -> Either<T, U>
::std::cmp::Eq
for Either<T, U>
where <T: ::std::cmp::Eq, U: ::std::cmp::Eq>
Automatically derived.
eq
fn eq(&self, __arg_0: &Either<T, U>) -> ::bool
ne
fn ne(&self, __arg_0: &Either<T, U>) -> ::bool
Either<T, U>
where <T, U>
either
fn either<V>(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V
flip
fn flip(self) -> Either<U, T>
to_result
fn to_result(self) -> Result<U, T>
is_left
fn is_left(&self) -> bool
is_right
fn is_right(&self) -> bool
unwrap_left
fn unwrap_left(self) -> T
unwrap_right
fn unwrap_right(self) -> U
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.
flip
fn flip<T, U>(eith: Either<T, U>) -> Either<U, T>
Flips between left and right of a given either
is_left
fn is_left<T, U>(eith: &Either<T, U>) -> bool
Checks whether the given value is a left
is_right
fn is_right<T, U>(eith: &Either<T, U>) -> bool
Checks whether the given value is a right
lefts
fn lefts<T: Copy, U>(eithers: &[Either<T, U>]) -> ~[T]
Extracts from a vector of either all the left values
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.
rights
fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U]
Extracts from a vector of either all the right values
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
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.
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.