diff --git a/src/libcollections/hash/mod.rs b/src/libcollections/hash/mod.rs index b867bb7be0422..a8b26ca3380c2 100644 --- a/src/libcollections/hash/mod.rs +++ b/src/libcollections/hash/mod.rs @@ -67,6 +67,7 @@ use core::prelude::*; use alloc::boxed::Box; use alloc::rc::Rc; +use core::cell::RefCell; use core::intrinsics::TypeId; use core::mem; @@ -239,6 +240,13 @@ impl> Hash for Rc { } } +impl> Hash for RefCell { + #[inline] + fn hash(&self, state: &mut S) { + self.borrow().hash(state); + } +} + impl> Hash for Option { #[inline] fn hash(&self, state: &mut S) { diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 2a7b1630edf68..ec69a04e3d294 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -156,10 +156,11 @@ // FIXME: Relationship to Atomic types and RWLock use clone::Clone; -use cmp::PartialEq; +use cmp::{PartialEq, Eq}; use kinds::{marker, Copy}; use ops::{Deref, DerefMut, Drop}; use option::{None, Option, Some}; +use std::fmt; /// A mutable memory location that admits only `Copy` data. #[unstable = "likely to be renamed; otherwise stable"] @@ -322,6 +323,16 @@ impl PartialEq for RefCell { } } +#[unstable = "waiting for `Eq` to become stable"] +impl Eq for RefCell {} + +#[unstable = "waiting for `Show` to become stable"] +impl fmt::Show for RefCell { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.borrow().fmt(f) + } +} + /// Wraps a borrowed reference to a value in a `RefCell` box. #[unstable] pub struct Ref<'b, T> {