Skip to content

Commit

Permalink
simplify PartialEq
Browse files Browse the repository at this point in the history
the iteration and checks are equivalent to ==, and using the operator is both more succinct and comes with potential compiler optimizations
  • Loading branch information
lonnen committed Jul 29, 2021
1 parent 260d0dd commit 34b399d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,12 +1065,7 @@ impl<T: Eq + Hash + Clone, S: BuildHasher + Default> ops::Sub<&MultiSet<T, S>> f

impl<T: Eq + Hash + Clone, S: BuildHasher> PartialEq for MultiSet<T, S> {
fn eq(&self, other: &MultiSet<T, S>) -> bool {
if self.len() != other.len() {
return false;
}

self.iter()
.all(|(key, value)| other.get(key).map_or(false, |v| *value == v))
self.len() == other.len()
}
}

Expand Down

0 comments on commit 34b399d

Please sign in to comment.