Skip to content

Commit 09cf660

Browse files
committed
---
yaml --- r: 151409 b: refs/heads/try2 c: a156534 h: refs/heads/master i: 151407: bfc35d9 v: v3
1 parent 2f241eb commit 09cf660

File tree

4 files changed

+23
-32
lines changed

4 files changed

+23
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f12b51705b064bbbeb86ad65663de476d07ad51f
8+
refs/heads/try2: a156534a96a6c401b14c80618c247eaadf876eb7
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/result.rs renamed to branches/try2/src/libcore/result.rs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,13 @@
268268
269269
use clone::Clone;
270270
use cmp::Eq;
271-
use std::fmt::Show;
272271
use iter::{Iterator, FromIterator};
273272
use option::{None, Option, Some};
274273

275274
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
276275
///
277276
/// See the [`std::result`](index.html) module documentation for details.
278-
#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Show, Hash)]
277+
#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd)]
279278
#[must_use]
280279
pub enum Result<T, E> {
281280
/// Contains the success value
@@ -516,34 +515,6 @@ impl<T, E> Result<T, E> {
516515
}
517516
}
518517

519-
impl<T, E: Show> Result<T, E> {
520-
/// Unwraps a result, yielding the content of an `Ok`.
521-
///
522-
/// Fails if the value is an `Err`.
523-
#[inline]
524-
pub fn unwrap(self) -> T {
525-
match self {
526-
Ok(t) => t,
527-
Err(e) =>
528-
fail!("called `Result::unwrap()` on an `Err` value: {}", e)
529-
}
530-
}
531-
}
532-
533-
impl<T: Show, E> Result<T, E> {
534-
/// Unwraps a result, yielding the content of an `Err`.
535-
///
536-
/// Fails if the value is an `Ok`.
537-
#[inline]
538-
pub fn unwrap_err(self) -> E {
539-
match self {
540-
Ok(t) =>
541-
fail!("called `Result::unwrap_err()` on an `Ok` value: {}", t),
542-
Err(e) => e
543-
}
544-
}
545-
}
546-
547518
/////////////////////////////////////////////////////////////////////////////
548519
// Free functions
549520
/////////////////////////////////////////////////////////////////////////////

branches/try2/src/libstd/fmt/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,15 @@ impl<T: Show> Show for Option<T> {
12911291
}
12921292
}
12931293

1294+
impl<T: Show, U: Show> Show for ::result::Result<T, U> {
1295+
fn fmt(&self, f: &mut Formatter) -> Result {
1296+
match *self {
1297+
Ok(ref t) => write!(f.buf, "Ok({})", *t),
1298+
Err(ref t) => write!(f.buf, "Err({})", *t),
1299+
}
1300+
}
1301+
}
1302+
12941303
impl<'a, T: Show> Show for &'a [T] {
12951304
fn fmt(&self, f: &mut Formatter) -> Result {
12961305
if f.flags & (1 << (parse::FlagAlternate as uint)) == 0 {

branches/try2/src/libstd/hash/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ use iter::Iterator;
7070
use option::{Option, Some, None};
7171
use owned::Box;
7272
use rc::Rc;
73-
use str::{Str, StrSlice};
73+
use result::{Result, Ok, Err};
7474
use slice::{Vector, ImmutableVector};
75+
use str::{Str, StrSlice};
7576
use vec::Vec;
7677

7778
/// Reexport the `sip::hash` function as our default hasher.
@@ -292,6 +293,16 @@ impl<S: Writer> Hash<S> for TypeId {
292293
}
293294
}
294295

296+
impl<S: Writer, T: Hash<S>, U: Hash<S>> Hash<S> for Result<T, U> {
297+
#[inline]
298+
fn hash(&self, state: &mut S) {
299+
match *self {
300+
Ok(ref t) => { 1u.hash(state); t.hash(state); }
301+
Err(ref t) => { 2u.hash(state); t.hash(state); }
302+
}
303+
}
304+
}
305+
295306
//////////////////////////////////////////////////////////////////////////////
296307

297308
#[cfg(test)]

0 commit comments

Comments
 (0)