From b662aa5ec0eb1971111bf10f9c3ef2a8f226bb0a Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Thu, 5 Jun 2014 23:22:01 -0700 Subject: [PATCH] Implement Eq for HashSet and HashMap Also fix documentation references to PartialEq. --- src/libstd/collections/hashmap.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libstd/collections/hashmap.rs b/src/libstd/collections/hashmap.rs index 5dba7a533a1..571c5794704 100644 --- a/src/libstd/collections/hashmap.rs +++ b/src/libstd/collections/hashmap.rs @@ -684,8 +684,8 @@ impl DefaultResizePolicy { /// denial-of-service attacks (Hash DoS). This behaviour can be /// overridden with one of the constructors. /// -/// It is required that the keys implement the `PartialEq` and `Hash` traits, although -/// this can frequently be achieved by using `#[deriving(PartialEq, Hash)]`. +/// It is required that the keys implement the `Eq` and `Hash` traits, although +/// this can frequently be achieved by using `#[deriving(Eq, Hash)]`. /// /// Relevant papers/articles: /// @@ -1422,6 +1422,8 @@ impl, V: PartialEq, S, H: Hasher> PartialEq for HashMap, V: Eq, S, H: Hasher> Eq for HashMap {} + impl + Show, V: Show, S, H: Hasher> Show for HashMap { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(write!(f, r"\{")); @@ -1486,7 +1488,7 @@ pub type SetMoveItems = /// An implementation of a hash set using the underlying representation of a /// HashMap where the value is (). As with the `HashMap` type, a `HashSet` -/// requires that the elements implement the `PartialEq` and `Hash` traits. +/// requires that the elements implement the `Eq` and `Hash` traits. #[deriving(Clone)] pub struct HashSet { map: HashMap @@ -1500,6 +1502,8 @@ impl, S, H: Hasher> PartialEq for HashSet { } } +impl, S, H: Hasher> Eq for HashSet {} + impl, S, H: Hasher> Container for HashSet { fn len(&self) -> uint { self.map.len() } }