diff options
| author | bors <bors@rust-lang.org> | 2014-12-17 16:43:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-17 16:43:20 +0000 |
| commit | 66c297d847ce06a8982d4d322221b17a3cd04f90 (patch) | |
| tree | 176a26b3e25b0e62d904e7af64476098e9f3e46e /src/liballoc | |
| parent | 2c533efd090e709a682468813aff36c368fdcd9d (diff) | |
| parent | 24a8ef63ff786dd702d428f73fd64aac2a828f19 (diff) | |
| download | rust-66c297d847ce06a8982d4d322221b17a3cd04f90.tar.gz rust-66c297d847ce06a8982d4d322221b17a3cd04f90.zip | |
auto merge of #19800 : sfackler/rust/core-hash, r=alexcrichton
r? @alexcrichton
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 9 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 9 |
3 files changed, 19 insertions, 1 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index b0ba20b0133..c6afeb063fb 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -15,6 +15,7 @@ use core::clone::Clone; use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering}; use core::default::Default; use core::fmt; +use core::hash::{mod, Hash}; use core::kinds::Sized; use core::mem; use core::option::Option; @@ -93,6 +94,14 @@ impl<Sized? T: Ord> Ord for Box<T> { } impl<Sized? T: Eq> Eq for Box<T> {} +impl<S: hash::Writer, Sized? T: Hash<S>> Hash<S> for Box<T> { + #[inline] + fn hash(&self, state: &mut S) { + (**self).hash(state); + } +} + + /// Extension methods for an owning `Any` trait object. #[unstable = "post-DST and coherence changes, this will not be a trait but \ rather a direct `impl` on `Box<Any>`"] diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 0b27fbd4404..61b5d43d1cb 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -64,7 +64,7 @@ html_root_url = "http://doc.rust-lang.org/nightly/")] #![no_std] -#![feature(lang_items, phase, unsafe_destructor)] +#![feature(lang_items, phase, unsafe_destructor, default_type_params)] #[phase(plugin, link)] extern crate core; diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 217c898e661..7af816f2e09 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -147,6 +147,7 @@ use core::clone::Clone; use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering}; use core::default::Default; use core::fmt; +use core::hash::{mod, Hash}; use core::kinds::marker; use core::mem::{transmute, min_align_of, size_of, forget}; use core::ops::{Deref, Drop}; @@ -594,6 +595,14 @@ impl<T: Ord> Ord for Rc<T> { fn cmp(&self, other: &Rc<T>) -> Ordering { (**self).cmp(&**other) } } +// FIXME (#18248) Make `T` `Sized?` +impl<S: hash::Writer, T: Hash<S>> Hash<S> for Rc<T> { + #[inline] + fn hash(&self, state: &mut S) { + (**self).hash(state); + } +} + #[experimental = "Show is experimental."] impl<T: fmt::Show> fmt::Show for Rc<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
