Skip to content

Commit 4c2e500

Browse files
committed
Auto merge of #101816 - raldone01:cleanup/select_nth_unstable, r=Mark-Simulacrum
Cleanup slice sort related closures in core and alloc
2 parents 65c16dc + 59fe291 commit 4c2e500

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

library/alloc/src/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl<T> [T] {
205205
where
206206
T: Ord,
207207
{
208-
merge_sort(self, |a, b| a.lt(b));
208+
merge_sort(self, T::lt);
209209
}
210210

211211
/// Sorts the slice with a comparator function.

library/core/src/slice/mod.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ impl<T> [T] {
25402540
where
25412541
T: Ord,
25422542
{
2543-
sort::quicksort(self, |a, b| a.lt(b));
2543+
sort::quicksort(self, T::lt);
25442544
}
25452545

25462546
/// Sorts the slice with a comparator function, but might not preserve the order of equal
@@ -2679,8 +2679,7 @@ impl<T> [T] {
26792679
where
26802680
T: Ord,
26812681
{
2682-
let mut f = |a: &T, b: &T| a.lt(b);
2683-
sort::partition_at_index(self, index, &mut f)
2682+
sort::partition_at_index(self, index, T::lt)
26842683
}
26852684

26862685
/// Reorder the slice with a comparator function such that the element at `index` is at its
@@ -2731,8 +2730,7 @@ impl<T> [T] {
27312730
where
27322731
F: FnMut(&T, &T) -> Ordering,
27332732
{
2734-
let mut f = |a: &T, b: &T| compare(a, b) == Less;
2735-
sort::partition_at_index(self, index, &mut f)
2733+
sort::partition_at_index(self, index, |a: &T, b: &T| compare(a, b) == Less)
27362734
}
27372735

27382736
/// Reorder the slice with a key extraction function such that the element at `index` is at its
@@ -2784,8 +2782,7 @@ impl<T> [T] {
27842782
F: FnMut(&T) -> K,
27852783
K: Ord,
27862784
{
2787-
let mut g = |a: &T, b: &T| f(a).lt(&f(b));
2788-
sort::partition_at_index(self, index, &mut g)
2785+
sort::partition_at_index(self, index, |a: &T, b: &T| f(a).lt(&f(b)))
27892786
}
27902787

27912788
/// Moves all consecutive repeated elements to the end of the slice according to the

0 commit comments

Comments
 (0)