Skip to content

Commit d62cf31

Browse files
committed
Fix collections::VecMap's PartialEq implementation
Previously it took capacity into account. Additionally remove the `ne` implementation of `RingBuf` which is the default one anyway.
1 parent 34d6800 commit d62cf31

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/libcollections/ring_buf.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1294,9 +1294,6 @@ impl<A: PartialEq> PartialEq for RingBuf<A> {
12941294
self.len() == other.len() &&
12951295
self.iter().zip(other.iter()).all(|(a, b)| a.eq(b))
12961296
}
1297-
fn ne(&self, other: &RingBuf<A>) -> bool {
1298-
!self.eq(other)
1299-
}
13001297
}
13011298

13021299
impl<A: Eq> Eq for RingBuf<A> {}

src/libcollections/vec_map.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ use vec::Vec;
6060
/// months.clear();
6161
/// assert!(months.is_empty());
6262
/// ```
63-
#[deriving(PartialEq, Eq)]
6463
pub struct VecMap<V> {
6564
v: Vec<Option<V>>,
6665
}
@@ -489,6 +488,14 @@ impl<V:Clone> VecMap<V> {
489488
}
490489
}
491490

491+
impl<V: PartialEq> PartialEq for VecMap<V> {
492+
fn eq(&self, other: &VecMap<V>) -> bool {
493+
iter::order::eq(self.iter(), other.iter())
494+
}
495+
}
496+
497+
impl<V: Eq> Eq for VecMap<V> {}
498+
492499
impl<V: PartialOrd> PartialOrd for VecMap<V> {
493500
#[inline]
494501
fn partial_cmp(&self, other: &VecMap<V>) -> Option<Ordering> {
@@ -952,6 +959,10 @@ mod test_map {
952959
assert!(a != b);
953960
assert!(b.insert(5, 19).is_none());
954961
assert!(a == b);
962+
963+
a = VecMap::new();
964+
b = VecMap::with_capacity(1);
965+
assert!(a == b);
955966
}
956967

957968
#[test]

0 commit comments

Comments
 (0)