Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,6 @@ impl cmp::PartialEq for BitvSet {
}
return true;
}

fn ne(&self, other: &BitvSet) -> bool { !self.eq(other) }
}

impl fmt::Show for BitvSet {
Expand Down
5 changes: 3 additions & 2 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,11 @@ fn raw_index(lo: uint, len: uint, index: uint) -> uint {
impl<A: PartialEq> PartialEq for RingBuf<A> {
fn eq(&self, other: &RingBuf<A>) -> bool {
self.nelts == other.nelts &&
self.iter().zip(other.iter()).all(|(a, b)| a.eq(b))
self.iter().zip(other.iter()).all(|(a, b)| a == b)
}
fn ne(&self, other: &RingBuf<A>) -> bool {
!self.eq(other)
self.nelts != other.nelts ||
self.iter().zip(other.iter()).any(|(a, b)| a != b)
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ impl<K: PartialEq + Ord, V: PartialEq> PartialEq for TreeMap<K, V> {
self.len() == other.len() &&
self.iter().zip(other.iter()).all(|(a, b)| a == b)
}
fn ne(&self, other: &TreeMap<K, V>) -> bool {
self.len() != other.len() ||
self.iter().zip(other.iter()).any(|(a, b)| a != b)
}
}

// Lexicographical comparison
Expand Down Expand Up @@ -559,6 +563,8 @@ pub struct TreeSet<T> {
impl<T: PartialEq + Ord> PartialEq for TreeSet<T> {
#[inline]
fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map }
#[inline]
fn ne(&self, other: &TreeSet<T>) -> bool { self.map != other.map }
}

impl<T: PartialOrd + Ord> PartialOrd for TreeSet<T> {
Expand Down
7 changes: 4 additions & 3 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ impl<T:Copy> Clone for Cell<T> {
}

impl<T:PartialEq + Copy> PartialEq for Cell<T> {
fn eq(&self, other: &Cell<T>) -> bool {
self.get() == other.get()
}
#[inline]
fn eq(&self, other: &Cell<T>) -> bool { self.get() == other.get() }
#[inline]
fn ne(&self, other: &Cell<T>) -> bool { self.get() != other.get() }
}

/// A mutable memory location with dynamically checked borrow rules
Expand Down
12 changes: 4 additions & 8 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,9 @@ impl<T> RawPtr<T> for *mut T {
#[cfg(not(test))]
impl<T> PartialEq for *T {
#[inline]
fn eq(&self, other: &*T) -> bool {
*self == *other
}
fn eq(&self, other: &*T) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &*T) -> bool { !self.eq(other) }
fn ne(&self, other: &*T) -> bool { *self != *other }
}

#[cfg(not(test))]
Expand All @@ -417,11 +415,9 @@ impl<T> Eq for *T {}
#[cfg(not(test))]
impl<T> PartialEq for *mut T {
#[inline]
fn eq(&self, other: &*mut T) -> bool {
*self == *other
}
fn eq(&self, other: &*mut T) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &*mut T) -> bool { !self.eq(other) }
fn ne(&self, other: &*mut T) -> bool { *self != *other }
}

#[cfg(not(test))]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ pub mod traits {
#[inline]
fn eq(&self, other: &~[T]) -> bool { self.as_slice() == *other }
#[inline]
fn ne(&self, other: &~[T]) -> bool { !self.eq(other) }
fn ne(&self, other: &~[T]) -> bool { self.as_slice() != *other }
}

impl<'a,T:Eq> Eq for &'a [T] {}
Expand Down
20 changes: 17 additions & 3 deletions src/libstd/collections/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,17 @@ impl<K: Eq + Hash<S>, V: PartialEq, S, H: Hasher<S>> PartialEq for HashMap<K, V,
}
})
}
fn ne(&self, other: &HashMap<K, V, H>) -> bool {
if self.len() != other.len() { return true; }

self.iter()
.any(|(key, value)| {
match other.find(key) {
None => true,
Some(v) => *value != *v
}
})
}
}

impl<K: Eq + Hash<S>, V: Eq, S, H: Hasher<S>> Eq for HashMap<K, V, H> {}
Expand Down Expand Up @@ -1495,10 +1506,13 @@ pub struct HashSet<T, H = sip::SipHasher> {
}

impl<T: Eq + Hash<S>, S, H: Hasher<S>> PartialEq for HashSet<T, H> {
#[inline]
fn eq(&self, other: &HashSet<T, H>) -> bool {
if self.len() != other.len() { return false; }

self.iter().all(|key| other.contains(key))
self.map == other.map
}
#[inline]
fn ne(&self, other: &HashSet<T, H>) -> bool {
self.map != other.map
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/libstd/collections/lru_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ impl<S, K: Hash<S>> Hash<S> for KeyRef<K> {
}

impl<K: PartialEq> PartialEq for KeyRef<K> {
fn eq(&self, other: &KeyRef<K>) -> bool {
unsafe{ (*self.k).eq(&*other.k) }
}
#[inline]
fn eq(&self, other: &KeyRef<K>) -> bool { unsafe { (&*self.k) == (&*other.k) } }
#[inline]
fn ne(&self, other: &KeyRef<K>) -> bool { unsafe { (&*self.k) != (&*other.k) } }
}

impl<K: Eq> Eq for KeyRef<K> {}
Expand Down