Skip to content

Commit

Permalink
Unrolled build for rust-lang#137484
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#137484 - chenyukang:yukang-fix-sort-doc, r=Noratrieb

Fix documentation for unstable sort on slice

Fixes rust-lang#136665
  • Loading branch information
rust-timer authored Feb 24, 2025
2 parents f43e549 + 1a440d5 commit 90b0c4c
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2928,10 +2928,17 @@ impl<T> [T] {
/// This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not
/// allocate), and *O*(*n* \* log(*n*)) worst-case.
///
/// If the implementation of [`Ord`] for `T` does not implement a [total order] the resulting
/// order of elements in the slice is unspecified. All original elements will remain in the
/// slice and any possible modifications via interior mutability are observed in the input. Same
/// is true if the implementation of [`Ord`] for `T` panics.
/// If the implementation of [`Ord`] for `T` does not implement a [total order], the function
/// may panic; even if the function exits normally, the resulting order of elements in the slice
/// is unspecified. See also the note on panicking below.
///
/// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor
/// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and
/// examples see the [`Ord`] documentation.
///
///
/// All original elements will remain in the slice and any possible modifications via interior
/// mutability are observed in the input. Same is true if the implementation of [`Ord`] for `T` panics.
///
/// Sorting types that only implement [`PartialOrd`] such as [`f32`] and [`f64`] require
/// additional precautions. For example, `f32::NAN != f32::NAN`, which doesn't fulfill the
Expand All @@ -2954,7 +2961,8 @@ impl<T> [T] {
///
/// # Panics
///
/// May panic if the implementation of [`Ord`] for `T` does not implement a [total order].
/// May panic if the implementation of [`Ord`] for `T` does not implement a [total order], or if
/// the [`Ord`] implementation panics.
///
/// # Examples
///
Expand Down Expand Up @@ -2982,15 +2990,17 @@ impl<T> [T] {
/// This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not
/// allocate), and *O*(*n* \* log(*n*)) worst-case.
///
/// If the comparison function `compare` does not implement a [total order] the resulting order
/// of elements in the slice is unspecified. All original elements will remain in the slice and
/// any possible modifications via interior mutability are observed in the input. Same is true
/// if `compare` panics.
/// If the comparison function `compare` does not implement a [total order], the function
/// may panic; even if the function exits normally, the resulting order of elements in the slice
/// is unspecified. See also the note on panicking below.
///
/// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor
/// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and
/// examples see the [`Ord`] documentation.
///
/// All original elements will remain in the slice and any possible modifications via interior
/// mutability are observed in the input. Same is true if `compare` panics.
///
/// # Current implementation
///
/// The current implementation is based on [ipnsort] by Lukas Bergdoll and Orson Peters, which
Expand All @@ -3003,7 +3013,8 @@ impl<T> [T] {
///
/// # Panics
///
/// May panic if `compare` does not implement a [total order].
/// May panic if the `compare` does not implement a [total order], or if
/// the `compare` itself panics.
///
/// # Examples
///
Expand Down Expand Up @@ -3034,10 +3045,16 @@ impl<T> [T] {
/// This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not
/// allocate), and *O*(*n* \* log(*n*)) worst-case.
///
/// If the implementation of [`Ord`] for `K` does not implement a [total order] the resulting
/// order of elements in the slice is unspecified. All original elements will remain in the
/// slice and any possible modifications via interior mutability are observed in the input. Same
/// is true if the implementation of [`Ord`] for `K` panics.
/// If the implementation of [`Ord`] for `K` does not implement a [total order], the function
/// may panic; even if the function exits normally, the resulting order of elements in the slice
/// is unspecified. See also the note on panicking below.
///
/// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor
/// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and
/// examples see the [`Ord`] documentation.
///
/// All original elements will remain in the slice and any possible modifications via interior
/// mutability are observed in the input. Same is true if the implementation of [`Ord`] for `K` panics.
///
/// # Current implementation
///
Expand All @@ -3051,7 +3068,8 @@ impl<T> [T] {
///
/// # Panics
///
/// May panic if the implementation of [`Ord`] for `K` does not implement a [total order].
/// May panic if the implementation of [`Ord`] for `K` does not implement a [total order], or if
/// the [`Ord`] implementation panics.
///
/// # Examples
///
Expand Down

0 comments on commit 90b0c4c

Please sign in to comment.