File tree 1 file changed +20
-0
lines changed 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ use core::cmp;
19
19
use core:: default:: Default ;
20
20
use core:: fmt;
21
21
use core:: iter:: RandomAccessIterator ;
22
+ use core:: iter;
22
23
use std:: hash:: { Writer , Hash } ;
23
24
24
25
use { Deque , Collection , Mutable , MutableSeq } ;
@@ -451,6 +452,12 @@ impl<A: PartialEq> PartialEq for RingBuf<A> {
451
452
}
452
453
}
453
454
455
+ impl < A : PartialOrd > PartialOrd for RingBuf < A > {
456
+ fn partial_cmp ( & self , other : & RingBuf < A > ) -> Option < Ordering > {
457
+ iter:: order:: partial_cmp ( self . iter ( ) , other. iter ( ) )
458
+ }
459
+ }
460
+
454
461
impl < S : Writer , A : Hash < S > > Hash < S > for RingBuf < A > {
455
462
fn hash ( & self , state : & mut S ) {
456
463
for elt in self . iter ( ) {
@@ -940,6 +947,19 @@ mod tests {
940
947
assert ! ( hash:: hash( & x) == hash:: hash( & y) ) ;
941
948
}
942
949
950
+ #[ test]
951
+ fn test_ord ( ) {
952
+ let x = RingBuf :: new ( ) ;
953
+ let mut y = RingBuf :: new ( ) ;
954
+ y. push ( 1 i) ;
955
+ y. push ( 2 ) ;
956
+ y. push ( 3 ) ;
957
+ assert ! ( x < y) ;
958
+ assert ! ( y > x) ;
959
+ assert ! ( x <= x) ;
960
+ assert ! ( x >= x) ;
961
+ }
962
+
943
963
#[ test]
944
964
fn test_show ( ) {
945
965
let ringbuf: RingBuf < int > = range ( 0 i, 10 ) . collect ( ) ;
You can’t perform that action at this time.
0 commit comments