Skip to content

Commit 31f0db0

Browse files
committed
---
yaml --- r: 125948 b: refs/heads/try c: 6361577 h: refs/heads/master v: v3
1 parent da28054 commit 31f0db0

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: f2fa55903e378368ed9173560f03a0ef16e371c2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9fc8394d3bce22ab483f98842434c84c396212ae
5-
refs/heads/try: 1cfa6569f9078090ac317af432adf712407bd4f7
5+
refs/heads/try: 63615778089545588ed15b7467bb3cca1c05c3a7
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcollections/ringbuf.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use core::cmp;
1919
use core::default::Default;
2020
use core::fmt;
2121
use core::iter::RandomAccessIterator;
22+
use core::iter;
2223
use std::hash::{Writer, Hash};
2324

2425
use {Deque, Collection, Mutable, MutableSeq};
@@ -451,6 +452,12 @@ impl<A: PartialEq> PartialEq for RingBuf<A> {
451452
}
452453
}
453454

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+
454461
impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {
455462
fn hash(&self, state: &mut S) {
456463
for elt in self.iter() {
@@ -940,6 +947,19 @@ mod tests {
940947
assert!(hash::hash(&x) == hash::hash(&y));
941948
}
942949

950+
#[test]
951+
fn test_ord() {
952+
let x = RingBuf::new();
953+
let mut y = RingBuf::new();
954+
y.push(1i);
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+
943963
#[test]
944964
fn test_show() {
945965
let ringbuf: RingBuf<int> = range(0i, 10).collect();

0 commit comments

Comments
 (0)