Skip to content

Commit 45fe205

Browse files
committed
Removed legacy implementations
1 parent c22e7f0 commit 45fe205

File tree

2 files changed

+0
-121
lines changed

2 files changed

+0
-121
lines changed

src/libstd/option.rs

-61
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ use clone::Clone;
4242
use clone::DeepClone;
4343
use cmp::{Eq, TotalEq, TotalOrd};
4444
use default::Default;
45-
use either;
4645
use fmt;
4746
use iter::{Iterator, DoubleEndedIterator, ExactSize};
4847
use kinds::Send;
49-
use num::Zero;
5048
use result::{IntoResult, ToResult, AsResult};
5149
use result::{Result, Ok, Err};
5250
use str::OwnedStr;
@@ -361,17 +359,6 @@ impl<T: Default> Option<T> {
361359
}
362360
}
363361

364-
impl<T: Zero> Option<T> {
365-
/// Returns the contained value or zero (for this type)
366-
#[inline]
367-
pub fn unwrap_or_zero(self) -> T {
368-
match self {
369-
Some(x) => x,
370-
None => Zero::zero()
371-
}
372-
}
373-
}
374-
375362
/////////////////////////////////////////////////////////////////////////////
376363
// Constructor extension trait
377364
/////////////////////////////////////////////////////////////////////////////
@@ -449,26 +436,6 @@ impl<T> AsResult<T, ()> for Option<T> {
449436
}
450437
}
451438

452-
impl<T: Clone> either::ToEither<(), T> for Option<T> {
453-
#[inline]
454-
fn to_either(&self) -> either::Either<(), T> {
455-
match *self {
456-
Some(ref x) => either::Right(x.clone()),
457-
None => either::Left(()),
458-
}
459-
}
460-
}
461-
462-
impl<T> either::IntoEither<(), T> for Option<T> {
463-
#[inline]
464-
fn into_either(self) -> either::Either<(), T> {
465-
match self {
466-
Some(x) => either::Right(x),
467-
None => either::Left(()),
468-
}
469-
}
470-
}
471-
472439
impl<T: fmt::Default> fmt::Default for Option<T> {
473440
#[inline]
474441
fn fmt(s: &Option<T>, f: &mut fmt::Formatter) {
@@ -526,8 +493,6 @@ impl<A> ExactSize<A> for OptionIterator<A> {}
526493
mod tests {
527494
use super::*;
528495

529-
use either::{IntoEither, ToEither};
530-
use either;
531496
use result::{IntoResult, ToResult};
532497
use result::{Result, Ok, Err};
533498
use str::StrSlice;
@@ -696,14 +661,6 @@ mod tests {
696661
assert_eq!(x.unwrap_or_else(|| 2), 2);
697662
}
698663

699-
#[test]
700-
fn test_unwrap_or_zero() {
701-
let some_stuff = Some(42);
702-
assert_eq!(some_stuff.unwrap_or_zero(), 42);
703-
let no_stuff: Option<int> = None;
704-
assert_eq!(no_stuff.unwrap_or_zero(), 0);
705-
}
706-
707664
#[test]
708665
fn test_filtered() {
709666
let some_stuff = Some(42);
@@ -820,22 +777,4 @@ mod tests {
820777
assert_eq!(some.into_result(), Ok(100));
821778
assert_eq!(none.into_result(), Err(()));
822779
}
823-
824-
#[test]
825-
pub fn test_to_either() {
826-
let some: Option<int> = Some(100);
827-
let none: Option<int> = None;
828-
829-
assert_eq!(some.to_either(), either::Right(100));
830-
assert_eq!(none.to_either(), either::Left(()));
831-
}
832-
833-
#[test]
834-
pub fn test_into_either() {
835-
let some: Option<int> = Some(100);
836-
let none: Option<int> = None;
837-
838-
assert_eq!(some.into_either(), either::Right(100));
839-
assert_eq!(none.into_either(), either::Left(()));
840-
}
841780
}

src/libstd/result.rs

-60
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use any::Any;
1414
use clone::Clone;
1515
use cmp::Eq;
16-
use either;
1716
use fmt;
1817
use iter::Iterator;
1918
use kinds::Send;
@@ -331,36 +330,6 @@ impl<T, E> AsOption<T> for Result<T, E> {
331330
}
332331
}
333332

334-
impl<T: Clone, E: Clone> either::ToEither<E, T> for Result<T, E> {
335-
#[inline]
336-
fn to_either(&self) -> either::Either<E, T> {
337-
match *self {
338-
Ok(ref t) => either::Right(t.clone()),
339-
Err(ref e) => either::Left(e.clone()),
340-
}
341-
}
342-
}
343-
344-
impl<T, E> either::IntoEither<E, T> for Result<T, E> {
345-
#[inline]
346-
fn into_either(self) -> either::Either<E, T> {
347-
match self {
348-
Ok(t) => either::Right(t),
349-
Err(e) => either::Left(e),
350-
}
351-
}
352-
}
353-
354-
impl<T, E> either::AsEither<E, T> for Result<T, E> {
355-
#[inline]
356-
fn as_either<'a>(&'a self) -> either::Either<&'a E, &'a T> {
357-
match *self {
358-
Ok(ref t) => either::Right(t),
359-
Err(ref e) => either::Left(e),
360-
}
361-
}
362-
}
363-
364333
impl<T: fmt::Default, E: fmt::Default> fmt::Default for Result<T, E> {
365334
#[inline]
366335
fn fmt(s: &Result<T, E>, f: &mut fmt::Formatter) {
@@ -444,8 +413,6 @@ pub fn fold_<T, E, Iter: Iterator<Result<T, E>>>(
444413
mod tests {
445414
use super::*;
446415

447-
use either::{IntoEither, ToEither, AsEither};
448-
use either;
449416
use iter::range;
450417
use option::{IntoOption, ToOption, AsOption};
451418
use option::{Option, Some, None};
@@ -631,33 +598,6 @@ mod tests {
631598
assert_eq!(err.as_result(), Err(&x));
632599
}
633600
634-
#[test]
635-
pub fn test_to_either() {
636-
let ok: Result<int, int> = Ok(100);
637-
let err: Result<int, int> = Err(404);
638-
639-
assert_eq!(ok.to_either(), either::Right(100));
640-
assert_eq!(err.to_either(), either::Left(404));
641-
}
642-
643-
#[test]
644-
pub fn test_into_either() {
645-
let ok: Result<int, int> = Ok(100);
646-
let err: Result<int, int> = Err(404);
647-
648-
assert_eq!(ok.into_either(), either::Right(100));
649-
assert_eq!(err.into_either(), either::Left(404));
650-
}
651-
652-
#[test]
653-
pub fn test_as_either() {
654-
let ok: Result<int, int> = Ok(100);
655-
let err: Result<int, int> = Err(404);
656-
657-
assert_eq!(ok.as_either().unwrap_right(), &100);
658-
assert_eq!(err.as_either().unwrap_left(), &404);
659-
}
660-
661601
#[test]
662602
pub fn test_to_str() {
663603
let ok: Result<int, ~str> = Ok(100);

0 commit comments

Comments
 (0)