diff --git a/src/libcore/core.rc b/src/libcore/core.rc index da50ff77c52..dfdd78d0591 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -184,7 +184,6 @@ mod ops; mod cmp; mod num; mod hash; -#[legacy_exports] mod either; #[legacy_exports] mod iter; diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 97ef66ad8de..dd3bcdfdf88 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -8,13 +8,13 @@ use cmp::Eq; use result::Result; /// The either type -enum Either { +pub enum Either { Left(T), Right(U) } -fn either(f_left: fn((&T)) -> V, - f_right: fn((&U)) -> V, value: &Either) -> V { +pub fn either(f_left: fn((&T)) -> V, + f_right: fn((&U)) -> V, value: &Either) -> V { /*! * Applies a function based on the given either value * @@ -29,7 +29,7 @@ fn either(f_left: fn((&T)) -> V, } } -fn lefts(eithers: &[Either]) -> ~[T] { +pub fn lefts(eithers: &[Either]) -> ~[T] { //! Extracts from a vector of either all the left values do vec::build_sized(eithers.len()) |push| { @@ -42,7 +42,7 @@ fn lefts(eithers: &[Either]) -> ~[T] { } } -fn rights(eithers: &[Either]) -> ~[U] { +pub fn rights(eithers: &[Either]) -> ~[U] { //! Extracts from a vector of either all the right values do vec::build_sized(eithers.len()) |push| { @@ -56,7 +56,7 @@ fn rights(eithers: &[Either]) -> ~[U] { } // XXX bad copies. take arg by val -fn partition(eithers: &[Either]) +pub fn partition(eithers: &[Either]) -> {lefts: ~[T], rights: ~[U]} { /*! * Extracts from a vector of either all the left values and right values @@ -77,7 +77,7 @@ fn partition(eithers: &[Either]) } // XXX bad copies -pure fn flip(eith: &Either) -> Either { +pub pure fn flip(eith: &Either) -> Either { //! Flips between left and right of a given either match *eith { @@ -87,7 +87,8 @@ pure fn flip(eith: &Either) -> Either { } // XXX bad copies -pure fn to_result(eith: &Either) -> Result { +pub pure fn to_result(eith: &Either) + -> Result { /*! * Converts either::t to a result::t * @@ -101,19 +102,19 @@ pure fn to_result(eith: &Either) -> Result { } } -pure fn is_left(eith: &Either) -> bool { +pub pure fn is_left(eith: &Either) -> bool { //! Checks whether the given value is a left match *eith { Left(_) => true, _ => false } } -pure fn is_right(eith: &Either) -> bool { +pub pure fn is_right(eith: &Either) -> bool { //! Checks whether the given value is a right match *eith { Right(_) => true, _ => false } } -pure fn unwrap_left(+eith: Either) -> T { +pub pure fn unwrap_left(+eith: Either) -> T { //! Retrieves the value in the left branch. Fails if the either is Right. match move eith { @@ -121,7 +122,7 @@ pure fn unwrap_left(+eith: Either) -> T { } } -pure fn unwrap_right(+eith: Either) -> U { +pub pure fn unwrap_right(+eith: Either) -> U { //! Retrieves the value in the right branch. Fails if the either is Left. match move eith {