diff options
| author | bors <bors@rust-lang.org> | 2013-08-14 02:38:19 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-14 02:38:19 -0700 |
| commit | cd656c74f67a289bb14c7758847a0fdd2e61d9a1 (patch) | |
| tree | 91b7c0959561ffa102f8dbcc9b3390cfdd83dbd8 /src/libstd | |
| parent | 0efbb25a26d9a793ce5aa67e030b3d0bee43f5fa (diff) | |
| parent | c8ca989c0786258d2024c04fd9633056c25a8ffb (diff) | |
| download | rust-cd656c74f67a289bb14c7758847a0fdd2e61d9a1.tar.gz rust-cd656c74f67a289bb14c7758847a0fdd2e61d9a1.zip | |
auto merge of #8439 : huonw/rust/hashset-clone, r=cmr
Closes #5581.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/hashmap.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index 7a224776859..201d4692694 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -745,6 +745,14 @@ impl<T:Hash + Eq> HashSet<T> { } +impl<T:Hash + Eq + Clone> Clone for HashSet<T> { + fn clone(&self) -> HashSet<T> { + HashSet { + map: self.map.clone() + } + } +} + impl<K: Eq + Hash, T: Iterator<K>> FromIterator<K, T> for HashSet<K> { fn from_iterator(iter: &mut T) -> HashSet<K> { let (lower, _) = iter.size_hint(); @@ -1190,4 +1198,22 @@ mod test_set { let v = hs.move_iter().collect::<~[char]>(); assert!(['a', 'b'] == v || ['b', 'a'] == v); } + + #[test] + fn test_eq() { + let mut s1 = HashSet::new(); + s1.insert(1); + s1.insert(2); + s1.insert(3); + + let mut s2 = HashSet::new(); + s2.insert(1); + s2.insert(2); + + assert!(s1 != s2); + + s2.insert(3); + + assert_eq!(s1, s2); + } } |
