From 159568eab51313490ca9faabd67b0e05bc129460 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Fri, 1 Feb 2013 16:37:38 -0800 Subject: [PATCH] core: Flesh out the either traits --- src/libcore/either.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 6b327b919e5..5e9ccd84195 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -150,6 +150,23 @@ pub pure fn unwrap_right(eith: Either) -> U { } impl Either { + #[inline(always)] + fn either(&self, f_left: fn(&T) -> V, f_right: fn(&U) -> V) -> V { + either(f_left, f_right, self) + } + + #[inline(always)] + fn flip(self) -> Either { flip(self) } + + #[inline(always)] + fn to_result(self) -> Result { to_result(self) } + + #[inline(always)] + fn is_left(&self) -> bool { is_left(self) } + + #[inline(always)] + fn is_right(&self) -> bool { is_right(self) } + #[inline(always)] fn unwrap_left(self) -> T { unwrap_left(self) }