Skip to content

Commit 000ec5e

Browse files
Made slice sort documentation consistent between stable and unstable versions
1 parent 1fe9b7f commit 000ec5e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

library/alloc/src/slice.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ mod hack {
169169
impl<T> [T] {
170170
/// Sorts the slice.
171171
///
172-
/// This sort is stable (i.e., does not reorder equal elements) and `O(n * log(n))` worst-case.
172+
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*n* \* log(*n*)) worst-case.
173173
///
174174
/// When applicable, unstable sorting is preferred because it is generally faster than stable
175175
/// sorting and it doesn't allocate auxiliary memory.
@@ -204,7 +204,7 @@ impl<T> [T] {
204204

205205
/// Sorts the slice with a comparator function.
206206
///
207-
/// This sort is stable (i.e., does not reorder equal elements) and `O(n * log(n))` worst-case.
207+
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*n* \* log(*n*)) worst-case.
208208
///
209209
/// The comparator function must define a total ordering for the elements in the slice. If
210210
/// the ordering is not total, the order of the elements is unspecified. An order is a
@@ -258,8 +258,8 @@ impl<T> [T] {
258258

259259
/// Sorts the slice with a key extraction function.
260260
///
261-
/// This sort is stable (i.e., does not reorder equal elements) and `O(m * n * log(n))`
262-
/// worst-case, where the key function is `O(m)`.
261+
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*m* \* *n* \* log(*n*))
262+
/// worst-case, where the key function is *O*(*m*).
263263
///
264264
/// For expensive key functions (e.g. functions that are not simple property accesses or
265265
/// basic operations), [`sort_by_cached_key`](#method.sort_by_cached_key) is likely to be
@@ -301,8 +301,8 @@ impl<T> [T] {
301301
///
302302
/// During sorting, the key function is called only once per element.
303303
///
304-
/// This sort is stable (i.e., does not reorder equal elements) and `O(m * n + n * log(n))`
305-
/// worst-case, where the key function is `O(m)`.
304+
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*m* \* *n* + *n* \* log(*n*))
305+
/// worst-case, where the key function is *O*(*m*).
306306
///
307307
/// For simple key functions (e.g., functions that are property accesses or
308308
/// basic operations), [`sort_by_key`](#method.sort_by_key) is likely to be
@@ -946,7 +946,7 @@ where
946946
/// 1. for every `i` in `1..runs.len()`: `runs[i - 1].len > runs[i].len`
947947
/// 2. for every `i` in `2..runs.len()`: `runs[i - 2].len > runs[i - 1].len + runs[i].len`
948948
///
949-
/// The invariants ensure that the total running time is `O(n * log(n))` worst-case.
949+
/// The invariants ensure that the total running time is *O*(*n* \* log(*n*)) worst-case.
950950
fn merge_sort<T, F>(v: &mut [T], mut is_less: F)
951951
where
952952
F: FnMut(&T, &T) -> bool,

library/core/src/slice/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1948,10 +1948,10 @@ impl<T> [T] {
19481948
///
19491949
/// The comparator function must define a total ordering for the elements in the slice. If
19501950
/// the ordering is not total, the order of the elements is unspecified. An order is a
1951-
/// total order if it is (for all a, b and c):
1951+
/// total order if it is (for all `a`, `b` and `c`):
19521952
///
1953-
/// * total and antisymmetric: exactly one of a < b, a == b or a > b is true; and
1954-
/// * transitive, a < b and b < c implies a < c. The same must hold for both == and >.
1953+
/// * total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b` is true, and
1954+
/// * transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
19551955
///
19561956
/// For example, while [`f64`] doesn't implement [`Ord`] because `NaN != NaN`, we can use
19571957
/// `partial_cmp` as our sort function when we know the slice doesn't contain a `NaN`.

0 commit comments

Comments
 (0)