diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2014-12-23 01:49:33 +0100 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2014-12-23 01:50:54 +0100 |
| commit | d62cf317aa2d229339ce2f9555e65560c66edb5f (patch) | |
| tree | 4d5c1cb4afdd13fe47f76f042e9c4a8bc11bdec8 /src | |
| parent | 34d680009205de2302b902d8f9f5f7ae7a042f1a (diff) | |
| download | rust-d62cf317aa2d229339ce2f9555e65560c66edb5f.tar.gz rust-d62cf317aa2d229339ce2f9555e65560c66edb5f.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcollections/ring_buf.rs | 3 | ||||
| -rw-r--r-- | src/libcollections/vec_map.rs | 13 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs index aa0e33248fc..27209f98cdb 100644 --- a/src/libcollections/ring_buf.rs +++ b/src/libcollections/ring_buf.rs @@ -1294,9 +1294,6 @@ impl<A: PartialEq> PartialEq for RingBuf<A> { self.len() == other.len() && self.iter().zip(other.iter()).all(|(a, b)| a.eq(b)) } - fn ne(&self, other: &RingBuf<A>) -> bool { - !self.eq(other) - } } impl<A: Eq> Eq for RingBuf<A> {} diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 1babde6066d..12e1a3dbad9 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -60,7 +60,6 @@ use vec::Vec; /// months.clear(); /// assert!(months.is_empty()); /// ``` -#[deriving(PartialEq, Eq)] pub struct VecMap<V> { v: Vec<Option<V>>, } @@ -489,6 +488,14 @@ impl<V:Clone> VecMap<V> { } } +impl<V: PartialEq> PartialEq for VecMap<V> { + fn eq(&self, other: &VecMap<V>) -> bool { + iter::order::eq(self.iter(), other.iter()) + } +} + +impl<V: Eq> Eq for VecMap<V> {} + impl<V: PartialOrd> PartialOrd for VecMap<V> { #[inline] fn partial_cmp(&self, other: &VecMap<V>) -> Option<Ordering> { @@ -952,6 +959,10 @@ mod test_map { assert!(a != b); assert!(b.insert(5, 19).is_none()); assert!(a == b); + + a = VecMap::new(); + b = VecMap::with_capacity(1); + assert!(a == b); } #[test] |
