diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-03-17 18:04:56 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-03-17 18:04:56 +0000 |
| commit | 0d53565b60c54bb3f88ec711e87d45a87502de73 (patch) | |
| tree | 169e7f4dd8cafdcab74515259cb059d2dea5bc0e /library/core/src | |
| parent | e4b9f86054c581d931f8bad0c87523c53e1e8e3f (diff) | |
| download | rust-0d53565b60c54bb3f88ec711e87d45a87502de73.tar.gz rust-0d53565b60c54bb3f88ec711e87d45a87502de73.zip | |
Make `slice::is_sorted_by` impl nicer
Diffstat (limited to 'library/core/src')
| -rw-r--r-- | library/core/src/slice/iter.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index c4317799bcc..68c7c5f23c9 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -132,9 +132,7 @@ iterator! {struct Iter -> *const T, &'a T, const, {/* no mut */}, { Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>, { - self.as_slice().windows(2).all(|w| { - compare(&&w[0], &&w[1]).map(|o| o != Ordering::Greater).unwrap_or(false) - }) + self.as_slice().array_windows().all(|[a, b]| compare(&a, &b).map_or(false, Ordering::is_le)) } }} |
