Add either::is_left and either::is_right

This commit is contained in:
Marijn Haverbeke 2012-01-04 16:36:53 +01:00
parent a7e1a35f88
commit e11d207113

@ -103,6 +103,24 @@ pure fn to_result<copy T, copy U>(eith: t<T, U>) -> result::t<U, T> {
}
}
/*
Function: is_left
Checks whether the given value is a left
*/
pure fn is_left<T, U>(eith: t<T, U>) -> bool {
alt eith { left(_) { true } _ { false } }
}
/*
Function: is_left
Checks whether the given value is a right
*/
pure fn is_right<T, U>(eith: t<T, U>) -> bool {
alt eith { right(_) { true } _ { false } }
}
//
// Local Variables:
// mode: rust