Skip to content

Commit d482589

Browse files
committed
core: use iterators for slice equality comparison
1 parent 30b27f3 commit d482589

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/libcore/slice/mod.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -5294,13 +5294,7 @@ impl<A, B> SlicePartialEq<B> for [A]
52945294
return false;
52955295
}
52965296

5297-
for i in 0..self.len() {
5298-
if !self[i].eq(&other[i]) {
5299-
return false;
5300-
}
5301-
}
5302-
5303-
true
5297+
self.iter().zip(other.iter()).all(|(x, y)| x == y)
53045298
}
53055299
}
53065300

@@ -5317,13 +5311,7 @@ impl<A> SlicePartialEq<A> for [A]
53175311
return true;
53185312
}
53195313

5320-
for i in 0..self.len() {
5321-
if !self[i].eq(&other[i]) {
5322-
return false;
5323-
}
5324-
}
5325-
5326-
true
5314+
self.iter().zip(other.iter()).all(|(x, y)| x == y)
53275315
}
53285316
}
53295317

0 commit comments

Comments
 (0)