File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
branches/snap-stage3/src/libcollections Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: 7be8f0af0393dcdb077c2f6b1653836fd3fba235
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
- refs/heads/snap-stage3: 3c453b36ce371da1339883f5e0157c5c13e7f9fd
4
+ refs/heads/snap-stage3: f7bcb736ad3a43a707aa915920b309e6bb13856b
5
5
refs/heads/try: 502e4c045236682e9728539dc0d2b3d0b237f55c
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ use core::fmt;
29
29
use core:: iter;
30
30
use core:: mem;
31
31
use core:: ptr;
32
+ use std:: hash:: { Writer , Hash } ;
32
33
33
34
use { Collection , Mutable , Deque , MutableSeq } ;
34
35
@@ -707,10 +708,20 @@ impl<A: fmt::Show> fmt::Show for DList<A> {
707
708
}
708
709
}
709
710
711
+ impl < S : Writer , A : Hash < S > > Hash < S > for DList < A > {
712
+ fn hash ( & self , state : & mut S ) {
713
+ self . len ( ) . hash ( state) ;
714
+ for elt in self . iter ( ) {
715
+ elt. hash ( state) ;
716
+ }
717
+ }
718
+ }
719
+
710
720
#[ cfg( test) ]
711
721
mod tests {
712
722
use std:: prelude:: * ;
713
723
use std:: rand;
724
+ use std:: hash;
714
725
use test:: Bencher ;
715
726
use test;
716
727
@@ -1075,6 +1086,24 @@ mod tests {
1075
1086
assert ! ( n != m) ;
1076
1087
}
1077
1088
1089
+ #[ test]
1090
+ fn test_hash ( ) {
1091
+ let mut x = DList :: new ( ) ;
1092
+ let mut y = DList :: new ( ) ;
1093
+
1094
+ assert ! ( hash:: hash( & x) == hash:: hash( & y) ) ;
1095
+
1096
+ x. push_back ( 1 i) ;
1097
+ x. push_back ( 2 ) ;
1098
+ x. push_back ( 3 ) ;
1099
+
1100
+ y. push_front ( 3 i) ;
1101
+ y. push_front ( 2 ) ;
1102
+ y. push_front ( 1 ) ;
1103
+
1104
+ assert ! ( hash:: hash( & x) == hash:: hash( & y) ) ;
1105
+ }
1106
+
1078
1107
#[ test]
1079
1108
fn test_ord ( ) {
1080
1109
let n: DList < int > = list_from ( [ ] ) ;
You can’t perform that action at this time.
0 commit comments