rust/library/alloc/src
Matthias Krüger 2a4381d8ea
Rollup merge of #89621 - digama0:patch-2, r=yaahc
doc: guarantee call order for sort_by_cached_key

`slice::sort_by_cached_key` takes a caching function `f: impl FnMut(&T) -> K`, which means that the order that calls to the caching function are made is user-visible. This adds a clause to the documentation to promise the current behavior, which is that `f` is called on all elements of the slice from left to right, unless the slice has len < 2 in which case `f` is not called.

For example, this can be used to ensure that the following code is a correct way to involve the index of the element in the sort key:
```rust
let mut index = 0;
slice.sort_by_cached_key(|x| (my_key(index, x), index += 1).0);
```
2022-01-19 10:42:13 +01:00
..
alloc Rename AllocRef to Allocator and (de)alloc to (de)allocate 2020-12-04 14:47:15 +01:00
collections Rollup merge of #92706 - umanwizard:btree, r=dtolnay 2022-01-16 16:58:16 +01:00
raw_vec Add a unit test for zero-sized types in RawVec. 2021-11-26 19:30:45 +11:00
rc Re-stabilize Weak::as_ptr &friends for unsized T 2021-01-06 19:30:22 -05:00
sync Rollup merge of #80764 - CAD97:weak-unsized-as-ptr-again, r=RalfJung 2021-01-16 17:29:56 +00:00
vec Rollup merge of #93016 - Amanieu:vec_spare_capacity, r=Mark-Simulacrum 2022-01-18 04:42:11 +01:00
alloc.rs Add tracking issues (const_box, const_alloc_error) 2022-01-04 00:35:53 +09:00
borrow.rs docs: fix typo 2021-12-18 11:21:58 +01:00
boxed.rs Add tracking issues (const_box, const_alloc_error) 2022-01-04 00:35:53 +09:00
fmt.rs Give examples of format args capture in the fmt module documentation 2021-11-15 10:13:44 +01:00
lib.rs Partially stabilize maybe_uninit_extra 2022-01-11 17:01:13 +01:00
macros.rs Add diagnostic items for macros 2022-01-06 14:59:33 +00:00
raw_vec.rs RawVec: don't recompute capacity after allocating. 2021-12-22 05:13:41 +11:00
rc.rs doc: fix typo in comments 2021-12-12 00:27:27 +01:00
slice.rs Rollup merge of #89621 - digama0:patch-2, r=yaahc 2022-01-19 10:42:13 +01:00
str.rs Use spare_capacity_mut instead of invalid unchecked indexing 2021-12-08 17:58:57 -05:00
string.rs Fix a minor mistake in String::try_reserve_exact examples 2021-12-29 13:22:35 +08:00
sync.rs doc: fix typo in comments 2021-12-12 00:27:27 +01:00
task.rs Document From implementations for Waker and RawWaker 2021-04-22 14:16:33 -07:00
tests.rs Fix alloc::test::test_show 2021-04-21 15:45:41 +02:00