File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -178,10 +178,15 @@ impl<T> [T] {
178
178
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*n* \* log(*n*))
179
179
/// worst-case.
180
180
///
181
- /// If the implementation of [`Ord`] for `T` does not implement a [total order] the resulting
182
- /// order of elements in the slice is unspecified. All original elements will remain in the
183
- /// slice and any possible modifications via interior mutability are observed in the input. Same
184
- /// is true if the implementation of [`Ord`] for `T` panics.
181
+ /// If the comparison function compare does not implement a [total order], the function may
182
+ /// panic; even if the function exits normally, the resulting order of elements in the slice is
183
+ /// unspecified.
184
+ ///
185
+ /// Even if `sort_by` or `compare` panics, all original elements will remain in the slice and
186
+ /// any possible modifications via interior mutability are observed in the input. This ensures
187
+ /// that recovery code (for instance inside of a `Drop` or following a `catch_unwind`) will
188
+ /// still have access to all the original elements. For instance, if the slice belongs to a
189
+ /// `Vec`, the `Vec::drop` method will be able to dispose of all contained elements.
185
190
///
186
191
/// When applicable, unstable sorting is preferred because it is generally faster than stable
187
192
/// sorting and it doesn't allocate auxiliary memory. See
You can’t perform that action at this time.
0 commit comments