Skip to content

Commit 0d53565

Browse files
committed
Make slice::is_sorted_by impl nicer
1 parent e4b9f86 commit 0d53565

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

library/core/src/slice/iter.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ iterator! {struct Iter -> *const T, &'a T, const, {/* no mut */}, {
132132
Self: Sized,
133133
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
134134
{
135-
self.as_slice().windows(2).all(|w| {
136-
compare(&&w[0], &&w[1]).map(|o| o != Ordering::Greater).unwrap_or(false)
137-
})
135+
self.as_slice().array_windows().all(|[a, b]| compare(&a, &b).map_or(false, Ordering::is_le))
138136
}
139137
}}
140138

0 commit comments

Comments
 (0)