mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-26 05:44:26 +00:00
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.
This commit is contained in:
parent
34d6800092
commit
d62cf317aa
@ -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> {}
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user