diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index 56774560d1d..deeda501942 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -255,11 +255,8 @@ impl HashMap { let len_buckets = self.buckets.len(); let bucket = self.buckets[idx].take(); - let value = match bucket { - None => None, - Some(Bucket{value, _}) => { - Some(value) - }, + let value = do bucket.map_consume |bucket| { + bucket.value }; /* re-inserting buckets may cause changes in size, so remember @@ -505,7 +502,6 @@ impl HashMap { // `consume_rev_iter` is more efficient than `consume_iter` for vectors HashMapConsumeIterator {iter: self.buckets.consume_rev_iter()} } - } impl HashMap { @@ -524,14 +520,12 @@ impl Eq for HashMap { fn eq(&self, other: &HashMap) -> bool { if self.len() != other.len() { return false; } - for self.iter().advance |(key, value)| { + do self.iter().all |(key, value)| { match other.find(key) { - None => return false, - Some(v) => if value != v { return false }, + None => false, + Some(v) => value == v } } - - true } fn ne(&self, other: &HashMap) -> bool { !self.eq(other) }