diff options
| author | Janik Rabe <info@janikrabe.com> | 2021-07-01 22:15:13 +0100 |
|---|---|---|
| committer | Janik Rabe <info@janikrabe.com> | 2021-07-01 22:15:13 +0100 |
| commit | 2dd69aaafc64fe9dce74088b5371a6cfb032e01e (patch) | |
| tree | 90447f6f75aafbd36b09c7b01371788c83bb6fc4 /library/std/src | |
| parent | 64de4979e8979836e7c029d69eb96e6f7da66185 (diff) | |
| download | rust-2dd69aaafc64fe9dce74088b5371a6cfb032e01e.tar.gz rust-2dd69aaafc64fe9dce74088b5371a6cfb032e01e.zip | |
Document iteration order of `retain` functions
For `HashSet` and `HashMap`, this simply copies the comment from `BinaryHeap::retain`. For `BTreeSet` and `BTreeMap`, this adds an additional guarantee that wasn't previously documented. I think that because these data structures are inherently ordered and other functions guarantee ordered iteration, it makes sense to provide this guarantee for `retain` as well.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/collections/hash/map.rs | 1 | ||||
| -rw-r--r-- | library/std/src/collections/hash/set.rs | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index a1f52a9c2e8..241f33746d6 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -936,6 +936,7 @@ where /// Retains only the elements specified by the predicate. /// /// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`. + /// The elements are visited in unsorted (and unspecified) order. /// /// # Examples /// diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 5220c8ad709..372feff7fa0 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -914,6 +914,7 @@ where /// Retains only the elements specified by the predicate. /// /// In other words, remove all elements `e` such that `f(&e)` returns `false`. + /// The elements are visited in unsorted (and unspecified) order. /// /// # Examples /// |
