diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-19 10:42:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-19 10:42:13 +0100 |
| commit | 2a4381d8eaad4f9f0eb5a4e624e7b154640690f1 (patch) | |
| tree | cd6e1a487e81f61a16e87f840e529d53d3631f43 /src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs | |
| parent | 5d2928f7b9eaea9c00ed7695143c0f71c5f53786 (diff) | |
| parent | 06b17a21813c2869ee50cbc4c8a92a04e40d2959 (diff) | |
| download | rust-2a4381d8eaad4f9f0eb5a4e624e7b154640690f1.tar.gz rust-2a4381d8eaad4f9f0eb5a4e624e7b154640690f1.zip | |
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); ```
Diffstat (limited to 'src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs')
0 files changed, 0 insertions, 0 deletions
