diff options
| -rw-r--r-- | library/core/src/slice/iter.rs | 2 | ||||
| -rw-r--r-- | library/core/src/slice/mod.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 68c7c5f23c9..88b84bd1352 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -132,7 +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().array_windows().all(|[a, b]| compare(&a, &b).map_or(false, Ordering::is_le)) + self.as_slice().is_sorted_by(|a, b| compare(&a, &b)) } }} diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index d319b2bc37f..57b6e0ce4bb 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -3822,7 +3822,7 @@ impl<T> [T] { where F: FnMut(&'a T, &'a T) -> Option<Ordering>, { - self.iter().is_sorted_by(|a, b| compare(*a, *b)) + self.array_windows().all(|[a, b]| compare(a, b).map_or(false, Ordering::is_le)) } /// Checks if the elements of this slice are sorted using the given key extraction function. |
