Rollup merge of #86790 - janikrabe:retain-iter-order-doc, r=m-ou-se
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.
This commit is contained in:
commit
249a11f936
4 changed files with 4 additions and 0 deletions
|
@ -935,6 +935,7 @@ impl<K, V> BTreeMap<K, V> {
|
||||||
/// Retains only the elements specified by the predicate.
|
/// Retains only the elements specified by the predicate.
|
||||||
///
|
///
|
||||||
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
|
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
|
||||||
|
/// The elements are visited in ascending key order.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
|
@ -846,6 +846,7 @@ impl<T> BTreeSet<T> {
|
||||||
/// Retains only the elements specified by the predicate.
|
/// Retains only the elements specified by the predicate.
|
||||||
///
|
///
|
||||||
/// In other words, remove all elements `e` such that `f(&e)` returns `false`.
|
/// In other words, remove all elements `e` such that `f(&e)` returns `false`.
|
||||||
|
/// The elements are visited in ascending order.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
|
@ -934,6 +934,7 @@ where
|
||||||
/// Retains only the elements specified by the predicate.
|
/// Retains only the elements specified by the predicate.
|
||||||
///
|
///
|
||||||
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
|
/// 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
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
|
@ -912,6 +912,7 @@ where
|
||||||
/// Retains only the elements specified by the predicate.
|
/// Retains only the elements specified by the predicate.
|
||||||
///
|
///
|
||||||
/// In other words, remove all elements `e` such that `f(&e)` returns `false`.
|
/// In other words, remove all elements `e` such that `f(&e)` returns `false`.
|
||||||
|
/// The elements are visited in unsorted (and unspecified) order.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Reference in a new issue