Skip to content

Commit 5e75ba0

Browse files
authored
Rollup merge of rust-lang#147101 - yotamofek:pr/iter-eq-and-eq-by, r=jdonszelmann
Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library Now that rust-lang#137122 has landed, we can replace stuff that looks like: ```rust let a: &[T]; let b: &[T]; let eq = a.len() == b.len() && a.iter().zip(b).all(|(a,b)| a == b) ``` with the much simpler `a.iter().eq(b)`, without losing the perf benefit of the different-length-fast-path. Also dogfooded `Iterator::eq_by` (cc rust-lang#64295 ) while I'm at it. First commit (4d1b6fa) should be very straightforward to review, second one (049a460) is slightly more creative, but IMHO a nice cleanup.
2 parents 1051518 + 522fdbe commit 5e75ba0

File tree

1 file changed

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

1 file changed

+1
-1
lines changed

alloc/src/collections/btree/map.rs

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

0 commit comments

Comments
 (0)