Skip to content

Commit 8900648

Browse files
committed
Merge pull request #19800 from sfackler/core-hash
Move hash module from collections to core Reviewed-by: alexcrichton
2 parents 6815a0e + 2c4effd commit 8900648

File tree

19 files changed

+697
-716
lines changed

19 files changed

+697
-716
lines changed

src/liballoc/boxed.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use core::clone::Clone;
1515
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
1616
use core::default::Default;
1717
use core::fmt;
18+
use core::hash::{mod, Hash};
1819
use core::kinds::Sized;
1920
use core::mem;
2021
use core::option::Option;
@@ -93,6 +94,14 @@ impl<Sized? T: Ord> Ord for Box<T> {
9394
}
9495
impl<Sized? T: Eq> Eq for Box<T> {}
9596

97+
impl<S: hash::Writer, Sized? T: Hash<S>> Hash<S> for Box<T> {
98+
#[inline]
99+
fn hash(&self, state: &mut S) {
100+
(**self).hash(state);
101+
}
102+
}
103+
104+
96105
/// Extension methods for an owning `Any` trait object.
97106
#[unstable = "post-DST and coherence changes, this will not be a trait but \
98107
rather a direct `impl` on `Box<Any>`"]

src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
html_root_url = "http://doc.rust-lang.org/nightly/")]
6565

6666
#![no_std]
67-
#![feature(lang_items, phase, unsafe_destructor)]
67+
#![feature(lang_items, phase, unsafe_destructor, default_type_params)]
6868

6969
#[phase(plugin, link)]
7070
extern crate core;

src/liballoc/rc.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ use core::clone::Clone;
147147
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
148148
use core::default::Default;
149149
use core::fmt;
150+
use core::hash::{mod, Hash};
150151
use core::kinds::marker;
151152
use core::mem::{transmute, min_align_of, size_of, forget};
152153
use core::ops::{Deref, Drop};
@@ -594,6 +595,14 @@ impl<T: Ord> Ord for Rc<T> {
594595
fn cmp(&self, other: &Rc<T>) -> Ordering { (**self).cmp(&**other) }
595596
}
596597

598+
// FIXME (#18248) Make `T` `Sized?`
599+
impl<S: hash::Writer, T: Hash<S>> Hash<S> for Rc<T> {
600+
#[inline]
601+
fn hash(&self, state: &mut S) {
602+
(**self).hash(state);
603+
}
604+
}
605+
597606
#[experimental = "Show is experimental."]
598607
impl<T: fmt::Show> fmt::Show for Rc<T> {
599608
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

0 commit comments

Comments
 (0)