diff options
| author | Steven Fackler <sfackler@gmail.com> | 2014-12-12 18:43:07 -0800 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2014-12-15 22:48:54 -0800 |
| commit | 24a8ef63ff786dd702d428f73fd64aac2a828f19 (patch) | |
| tree | 6f47ec4857a28ae6b8f01e20742d089edf2dcd1a /src/liballoc | |
| parent | b497f050081886803682adc081ddb1e8c4a59a57 (diff) | |
| download | rust-24a8ef63ff786dd702d428f73fd64aac2a828f19.tar.gz rust-24a8ef63ff786dd702d428f73fd64aac2a828f19.zip | |
Move hash module from collections to core
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 { |
