Skip to content

Commit 159568e

Browse files
committed
core: Flesh out the either traits
1 parent f4ed7d9 commit 159568e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/libcore/either.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,23 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
150150
}
151151

152152
impl<T, U> Either<T, U> {
153+
#[inline(always)]
154+
fn either<V>(&self, f_left: fn(&T) -> V, f_right: fn(&U) -> V) -> V {
155+
either(f_left, f_right, self)
156+
}
157+
158+
#[inline(always)]
159+
fn flip(self) -> Either<U, T> { flip(self) }
160+
161+
#[inline(always)]
162+
fn to_result(self) -> Result<U, T> { to_result(self) }
163+
164+
#[inline(always)]
165+
fn is_left(&self) -> bool { is_left(self) }
166+
167+
#[inline(always)]
168+
fn is_right(&self) -> bool { is_right(self) }
169+
153170
#[inline(always)]
154171
fn unwrap_left(self) -> T { unwrap_left(self) }
155172

0 commit comments

Comments
 (0)