diff --git a/src/libstd/collections/hashmap.rs b/src/libstd/collections/hashmap.rs index 098e87243b69c..20c7e1c695d87 100644 --- a/src/libstd/collections/hashmap.rs +++ b/src/libstd/collections/hashmap.rs @@ -11,7 +11,8 @@ //! Unordered containers, implemented as hash-tables (`HashSet` and `HashMap` types) use clone::Clone; -use cmp::{max, Eq, Equiv, PartialEq}; +use cmp; +use cmp::{max, Eq, Equiv, PartialEq, PartialOrd, Ordering}; use collections::{Collection, Mutable, Set, MutableSet, Map, MutableMap}; use default::Default; use fmt::Show; @@ -1499,6 +1500,18 @@ impl, S, H: Hasher> PartialEq for HashSet { impl, S, H: Hasher> Eq for HashSet {} +impl, S, H: Hasher> PartialOrd for HashSet { + #[inline] + fn partial_cmp(&self, other: &HashSet) -> Option { + match (self.is_subset(other), other.is_subset(self)) { + (true, true) => Some(cmp::Equal), + (true, false) => Some(cmp::Less), + (false, true) => Some(cmp::Greater), + (false, false) => None + } + } +} + impl, S, H: Hasher> Collection for HashSet { fn len(&self) -> uint { self.map.len() } }