summary refs log tree commit diff
path: root/src/libstd/hash
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-05-01 11:11:28 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-05-07 08:16:14 -0700
commita156534a96a6c401b14c80618c247eaadf876eb7 (patch)
tree3970353a35afc4604ffe188ac633be50a22946f2 /src/libstd/hash
parentf12b51705b064bbbeb86ad65663de476d07ad51f (diff)
downloadrust-a156534a96a6c401b14c80618c247eaadf876eb7.tar.gz
rust-a156534a96a6c401b14c80618c247eaadf876eb7.zip
core: Inherit the result module
The unwrap()/unwrap_err() methods are temporarily removed, and will be added
back in the next commit.
Diffstat (limited to 'src/libstd/hash')
-rw-r--r--src/libstd/hash/mod.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstd/hash/mod.rs b/src/libstd/hash/mod.rs
index 010ddbaa942..c8207a4c37c 100644
--- a/src/libstd/hash/mod.rs
+++ b/src/libstd/hash/mod.rs
@@ -70,8 +70,9 @@ use iter::Iterator;
 use option::{Option, Some, None};
 use owned::Box;
 use rc::Rc;
-use str::{Str, StrSlice};
+use result::{Result, Ok, Err};
 use slice::{Vector, ImmutableVector};
+use str::{Str, StrSlice};
 use vec::Vec;
 
 /// Reexport the `sip::hash` function as our default hasher.
@@ -292,6 +293,16 @@ impl<S: Writer> Hash<S> for TypeId {
     }
 }
 
+impl<S: Writer, T: Hash<S>, U: Hash<S>> Hash<S> for Result<T, U> {
+    #[inline]
+    fn hash(&self, state: &mut S) {
+        match *self {
+            Ok(ref t) => { 1u.hash(state); t.hash(state); }
+            Err(ref t) => { 2u.hash(state); t.hash(state); }
+        }
+    }
+}
+
 //////////////////////////////////////////////////////////////////////////////
 
 #[cfg(test)]