Skip to content

Commit e11d207

Browse files
committed
Add either::is_left and either::is_right
1 parent a7e1a35 commit e11d207

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/libcore/either.rs

+18
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ pure fn to_result<copy T, copy U>(eith: t<T, U>) -> result::t<U, T> {
103103
}
104104
}
105105

106+
/*
107+
Function: is_left
108+
109+
Checks whether the given value is a left
110+
*/
111+
pure fn is_left<T, U>(eith: t<T, U>) -> bool {
112+
alt eith { left(_) { true } _ { false } }
113+
}
114+
115+
/*
116+
Function: is_left
117+
118+
Checks whether the given value is a right
119+
*/
120+
pure fn is_right<T, U>(eith: t<T, U>) -> bool {
121+
alt eith { right(_) { true } _ { false } }
122+
}
123+
106124
//
107125
// Local Variables:
108126
// mode: rust

0 commit comments

Comments
 (0)