File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
branches/try/src/libcollections Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: f2fa55903e378368ed9173560f03a0ef16e371c2
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 9fc8394d3bce22ab483f98842434c84c396212ae
5
- refs/heads/try: 1cfa6569f9078090ac317af432adf712407bd4f7
5
+ refs/heads/try: 63615778089545588ed15b7467bb3cca1c05c3a7
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
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