File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -745,6 +745,14 @@ impl<T:Hash + Eq> HashSet<T> {
745
745
746
746
}
747
747
748
+ impl < T : Hash + Eq + Clone > Clone for HashSet < T > {
749
+ fn clone ( & self ) -> HashSet < T > {
750
+ HashSet {
751
+ map : self . map . clone ( )
752
+ }
753
+ }
754
+ }
755
+
748
756
impl < K : Eq + Hash , T : Iterator < K > > FromIterator < K , T > for HashSet < K > {
749
757
fn from_iterator ( iter : & mut T ) -> HashSet < K > {
750
758
let ( lower, _) = iter. size_hint ( ) ;
@@ -1190,4 +1198,22 @@ mod test_set {
1190
1198
let v = hs. consume ( ) . collect :: < ~[ char ] > ( ) ;
1191
1199
assert ! ( [ 'a' , 'b' ] == v || [ 'b' , 'a' ] == v) ;
1192
1200
}
1201
+
1202
+ #[ test]
1203
+ fn test_eq ( ) {
1204
+ let mut s1 = HashSet :: new ( ) ;
1205
+ s1. insert ( 1 ) ;
1206
+ s1. insert ( 2 ) ;
1207
+ s1. insert ( 3 ) ;
1208
+
1209
+ let mut s2 = HashSet :: new ( ) ;
1210
+ s2. insert ( 1 ) ;
1211
+ s2. insert ( 2 ) ;
1212
+
1213
+ assert ! ( s1 != s2) ;
1214
+
1215
+ s2. insert ( 3 ) ;
1216
+
1217
+ assert_eq ! ( s1, s2) ;
1218
+ }
1193
1219
}
You can’t perform that action at this time.
0 commit comments