Skip to content

Commit 4adcdbb

Browse files
committed
In BTreeMap::eq, do not compare the elements if the sizes are different.
Reverts 68a7c25 in library/
1 parent d2f8873 commit 4adcdbb

File tree

1 file changed

+1
-1
lines changed
  • library/alloc/src/collections/btree

1 file changed

+1
-1
lines changed

library/alloc/src/collections/btree/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2416,7 +2416,7 @@ impl<K, V> Default for BTreeMap<K, V> {
24162416
#[stable(feature = "rust1", since = "1.0.0")]
24172417
impl<K: PartialEq, V: PartialEq, A: Allocator + Clone> PartialEq for BTreeMap<K, V, A> {
24182418
fn eq(&self, other: &BTreeMap<K, V, A>) -> bool {
2419-
self.iter().eq(other)
2419+
self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a == b)
24202420
}
24212421
}
24222422

0 commit comments

Comments
 (0)