diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2013-11-01 14:36:43 +0100 |
|---|---|---|
| committer | Marvin Löbel <loebel.marvin@gmail.com> | 2013-11-01 15:01:56 +0100 |
| commit | 45fe20515ce13a99354625a14b3f71b86765c896 (patch) | |
| tree | 8cb8ab49e35182d006f05c627ad353f60a14930d /src/libstd | |
| parent | c22e7f02d11ff6c6741cdf0847bb7b77dbc5e868 (diff) | |
| download | rust-45fe20515ce13a99354625a14b3f71b86765c896.tar.gz rust-45fe20515ce13a99354625a14b3f71b86765c896.zip | |
Removed legacy implementations
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/option.rs | 61 | ||||
| -rw-r--r-- | src/libstd/result.rs | 60 |
2 files changed, 0 insertions, 121 deletions
diff --git a/src/libstd/option.rs b/src/libstd/option.rs index ad81dfd6517..e40666b8a33 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -42,11 +42,9 @@ use clone::Clone; use clone::DeepClone; use cmp::{Eq, TotalEq, TotalOrd}; use default::Default; -use either; use fmt; use iter::{Iterator, DoubleEndedIterator, ExactSize}; use kinds::Send; -use num::Zero; use result::{IntoResult, ToResult, AsResult}; use result::{Result, Ok, Err}; use str::OwnedStr; @@ -361,17 +359,6 @@ impl<T: Default> Option<T> { } } -impl<T: Zero> Option<T> { - /// Returns the contained value or zero (for this type) - #[inline] - pub fn unwrap_or_zero(self) -> T { - match self { - Some(x) => x, - None => Zero::zero() - } - } -} - ///////////////////////////////////////////////////////////////////////////// // Constructor extension trait ///////////////////////////////////////////////////////////////////////////// @@ -449,26 +436,6 @@ impl<T> AsResult<T, ()> for Option<T> { } } -impl<T: Clone> either::ToEither<(), T> for Option<T> { - #[inline] - fn to_either(&self) -> either::Either<(), T> { - match *self { - Some(ref x) => either::Right(x.clone()), - None => either::Left(()), - } - } -} - -impl<T> either::IntoEither<(), T> for Option<T> { - #[inline] - fn into_either(self) -> either::Either<(), T> { - match self { - Some(x) => either::Right(x), - None => either::Left(()), - } - } -} - impl<T: fmt::Default> fmt::Default for Option<T> { #[inline] fn fmt(s: &Option<T>, f: &mut fmt::Formatter) { @@ -526,8 +493,6 @@ impl<A> ExactSize<A> for OptionIterator<A> {} mod tests { use super::*; - use either::{IntoEither, ToEither}; - use either; use result::{IntoResult, ToResult}; use result::{Result, Ok, Err}; use str::StrSlice; @@ -697,14 +662,6 @@ mod tests { } #[test] - fn test_unwrap_or_zero() { - let some_stuff = Some(42); - assert_eq!(some_stuff.unwrap_or_zero(), 42); - let no_stuff: Option<int> = None; - assert_eq!(no_stuff.unwrap_or_zero(), 0); - } - - #[test] fn test_filtered() { let some_stuff = Some(42); let modified_stuff = some_stuff.filtered(|&x| {x < 10}); @@ -820,22 +777,4 @@ mod tests { assert_eq!(some.into_result(), Ok(100)); assert_eq!(none.into_result(), Err(())); } - - #[test] - pub fn test_to_either() { - let some: Option<int> = Some(100); - let none: Option<int> = None; - - assert_eq!(some.to_either(), either::Right(100)); - assert_eq!(none.to_either(), either::Left(())); - } - - #[test] - pub fn test_into_either() { - let some: Option<int> = Some(100); - let none: Option<int> = None; - - assert_eq!(some.into_either(), either::Right(100)); - assert_eq!(none.into_either(), either::Left(())); - } } diff --git a/src/libstd/result.rs b/src/libstd/result.rs index dcc910281ab..768de7dfc1f 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -13,7 +13,6 @@ use any::Any; use clone::Clone; use cmp::Eq; -use either; use fmt; use iter::Iterator; use kinds::Send; @@ -331,36 +330,6 @@ impl<T, E> AsOption<T> for Result<T, E> { } } -impl<T: Clone, E: Clone> either::ToEither<E, T> for Result<T, E> { - #[inline] - fn to_either(&self) -> either::Either<E, T> { - match *self { - Ok(ref t) => either::Right(t.clone()), - Err(ref e) => either::Left(e.clone()), - } - } -} - -impl<T, E> either::IntoEither<E, T> for Result<T, E> { - #[inline] - fn into_either(self) -> either::Either<E, T> { - match self { - Ok(t) => either::Right(t), - Err(e) => either::Left(e), - } - } -} - -impl<T, E> either::AsEither<E, T> for Result<T, E> { - #[inline] - fn as_either<'a>(&'a self) -> either::Either<&'a E, &'a T> { - match *self { - Ok(ref t) => either::Right(t), - Err(ref e) => either::Left(e), - } - } -} - impl<T: fmt::Default, E: fmt::Default> fmt::Default for Result<T, E> { #[inline] fn fmt(s: &Result<T, E>, f: &mut fmt::Formatter) { @@ -444,8 +413,6 @@ pub fn fold_<T, E, Iter: Iterator<Result<T, E>>>( mod tests { use super::*; - use either::{IntoEither, ToEither, AsEither}; - use either; use iter::range; use option::{IntoOption, ToOption, AsOption}; use option::{Option, Some, None}; @@ -632,33 +599,6 @@ mod tests { } #[test] - pub fn test_to_either() { - let ok: Result<int, int> = Ok(100); - let err: Result<int, int> = Err(404); - - assert_eq!(ok.to_either(), either::Right(100)); - assert_eq!(err.to_either(), either::Left(404)); - } - - #[test] - pub fn test_into_either() { - let ok: Result<int, int> = Ok(100); - let err: Result<int, int> = Err(404); - - assert_eq!(ok.into_either(), either::Right(100)); - assert_eq!(err.into_either(), either::Left(404)); - } - - #[test] - pub fn test_as_either() { - let ok: Result<int, int> = Ok(100); - let err: Result<int, int> = Err(404); - - assert_eq!(ok.as_either().unwrap_right(), &100); - assert_eq!(err.as_either().unwrap_left(), &404); - } - - #[test] pub fn test_to_str() { let ok: Result<int, ~str> = Ok(100); let err: Result<int, ~str> = Err(~"Err"); |
