diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 56fb7e3632e0..c6c55b55e332 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -24,6 +24,8 @@ use core::mem::replace; use {Collection, Mutable, Map, MutableMap, MutableSeq}; use {vec, slice}; use vec::Vec; +use hash; +use hash::Hash; /// A map optimized for small integer keys. /// @@ -58,7 +60,7 @@ use vec::Vec; /// months.clear(); /// assert!(months.is_empty()); /// ``` -#[deriving(Hash, PartialEq, Eq)] +#[deriving(PartialEq, Eq)] pub struct SmallIntMap { v: Vec>, } @@ -167,6 +169,12 @@ impl Clone for SmallIntMap { } } +impl > Hash for SmallIntMap { + fn hash(&self, state: &mut S) { + self.v.hash(state) + } +} + impl SmallIntMap { /// Create an empty SmallIntMap. /// @@ -478,8 +486,8 @@ pub type Values<'a, T> = #[cfg(test)] mod test_map { use std::prelude::*; - use std::hash; use vec::Vec; + use hash; use {Map, MutableMap, Mutable, MutableSeq}; use super::SmallIntMap; @@ -764,19 +772,19 @@ mod test_map { #[test] fn test_hash() { - let mut x = SmallIntMap::new(); - let mut y = SmallIntMap::new(); + let mut x = SmallIntMap::new(); + let mut y = SmallIntMap::new(); - assert!(hash::hash(&x) == hash::hash(&y)); - x.insert(1, 'a'); - x.insert(2, 'b'); - x.insert(3, 'c'); + assert!(hash::hash(&x) == hash::hash(&y)); + x.insert(1, 'a'); + x.insert(2, 'b'); + x.insert(3, 'c'); - y.insert(3, 'c'); - y.insert(2, 'b'); - y.insert(1, 'a'); + y.insert(3, 'c'); + y.insert(2, 'b'); + y.insert(1, 'a'); - assert!(hash::hash(&x) == hash::hash(&y)); + assert!(hash::hash(&x) == hash::hash(&y)); } #[test]