Skip to content

Commit 8c50ee3

Browse files
committed
auto merge of #7530 : alexcrichton/rust/issue-5194, r=thestinger
Closes #5194
2 parents e89dcb8 + 87b6129 commit 8c50ee3

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/libextra/treemap.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,25 @@ impl<K: Eq + TotalOrd, V: Eq> Eq for TreeMap<K, V> {
5757
}
5858

5959
// Lexicographical comparison
60-
fn lt<K: Ord + TotalOrd, V>(a: &TreeMap<K, V>,
60+
fn lt<K: Ord + TotalOrd, V: Ord>(a: &TreeMap<K, V>,
6161
b: &TreeMap<K, V>) -> bool {
6262
let mut x = a.iter();
6363
let mut y = b.iter();
6464

6565
let (a_len, b_len) = (a.len(), b.len());
6666
for uint::min(a_len, b_len).times {
67-
let (key_a,_) = x.next().unwrap();
68-
let (key_b,_) = y.next().unwrap();
67+
let (key_a, value_a) = x.next().unwrap();
68+
let (key_b, value_b) = y.next().unwrap();
6969
if *key_a < *key_b { return true; }
7070
if *key_a > *key_b { return false; }
71-
};
71+
if *value_a < *value_b { return true; }
72+
if *value_a > *value_b { return false; }
73+
}
7274

7375
a_len < b_len
7476
}
7577

76-
impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {
78+
impl<K: Ord + TotalOrd, V: Ord> Ord for TreeMap<K, V> {
7779
#[inline]
7880
fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) }
7981
#[inline]
@@ -935,7 +937,7 @@ mod test_treemap {
935937
assert!(b.insert(0, 5));
936938
assert!(a < b);
937939
assert!(a.insert(0, 7));
938-
assert!(!(a < b) && !(b < a));
940+
assert!(!(a < b) && b < a);
939941
assert!(b.insert(-2, 0));
940942
assert!(b < a);
941943
assert!(a.insert(-5, 2));

0 commit comments

Comments
 (0)