Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify ambiguity in select_nth_unstable docs #119481

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3047,7 +3047,7 @@ impl<T> [T] {
sort::quicksort(self, |a, b| f(a).lt(&f(b)));
}

/// Reorder the slice such that the element at `index` is at its final sorted position.
/// Reorder the slice such that the element at `index` after the reordering is at its final sorted position.
///
/// This reordering has the additional property that any value at position `i < index` will be
/// less than or equal to any value at a position `j > index`. Additionally, this reordering is
Expand Down Expand Up @@ -3075,7 +3075,7 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// let mut v = [-5i32, 4, 1, -3, 2];
/// let mut v = [-5i32, 4, 2, -3, 1];
///
/// // Find the median
/// v.select_nth_unstable(2);
Expand All @@ -3096,8 +3096,8 @@ impl<T> [T] {
select::partition_at_index(self, index, T::lt)
}

/// Reorder the slice with a comparator function such that the element at `index` is at its
/// final sorted position.
/// Reorder the slice with a comparator function such that the element at `index` after the reordering is at
/// its final sorted position.
///
/// This reordering has the additional property that any value at position `i < index` will be
/// less than or equal to any value at a position `j > index` using the comparator function.
Expand Down Expand Up @@ -3126,7 +3126,7 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// let mut v = [-5i32, 4, 1, -3, 2];
/// let mut v = [-5i32, 4, 2, -3, 1];
///
/// // Find the median as if the slice were sorted in descending order.
/// v.select_nth_unstable_by(2, |a, b| b.cmp(a));
Expand All @@ -3151,8 +3151,8 @@ impl<T> [T] {
select::partition_at_index(self, index, |a: &T, b: &T| compare(a, b) == Less)
}

/// Reorder the slice with a key extraction function such that the element at `index` is at its
/// final sorted position.
/// Reorder the slice with a key extraction function such that the element at `index` after the reordering is
/// at its final sorted position.
///
/// This reordering has the additional property that any value at position `i < index` will be
/// less than or equal to any value at a position `j > index` using the key extraction function.
Expand Down
Loading