Removed legacy implementations

This commit is contained in:
Marvin Löbel 2013-11-01 14:36:43 +01:00
parent c22e7f02d1
commit 45fe20515c
2 changed files with 0 additions and 121 deletions

View file

@ -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;
@ -696,14 +661,6 @@ mod tests {
assert_eq!(x.unwrap_or_else(|| 2), 2);
}
#[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);
@ -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(()));
}
}

View file

@ -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};
@ -631,33 +598,6 @@ mod tests {
assert_eq!(err.as_result(), Err(&x));
}
#[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);