Rollup merge of #86789 - janikrabe:btreeset-drainfilter-doc, r=kennytm

Update BTreeSet::drain_filter documentation

This commit makes the documentation of `BTreeSet::drain_filter` more
consistent with that of `BTreeMap::drain_filter` after the changes in
f0b8166870.

In particular, this explicitly documents the iteration order.
This commit is contained in:
Guillaume Gomez 2021-07-08 18:30:34 +02:00 committed by GitHub
commit ff4bf73a42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -940,18 +940,20 @@ impl<T> BTreeSet<T> {
BTreeSet { map: self.map.split_off(key) } BTreeSet { map: self.map.split_off(key) }
} }
/// Creates an iterator which uses a closure to determine if a value should be removed. /// Creates an iterator that visits all values in ascending order and uses a closure
/// to determine if a value should be removed.
/// ///
/// If the closure returns true, then the value is removed and yielded. /// If the closure returns `true`, the value is removed from the set and yielded. If
/// If the closure returns false, the value will remain in the list and will not be yielded /// the closure returns `false`, or panics, the value remains in the set and will
/// by the iterator. /// not be yielded.
/// ///
/// If the iterator is only partially consumed or not consumed at all, each of the remaining /// If the iterator is only partially consumed or not consumed at all, each of the
/// values will still be subjected to the closure and removed and dropped if it returns true. /// remaining values is still subjected to the closure and removed and dropped if it
/// returns `true`.
/// ///
/// It is unspecified how many more values will be subjected to the closure /// It is unspecified how many more values will be subjected to the closure if a
/// if a panic occurs in the closure, or if a panic occurs while dropping a value, or if the /// panic occurs in the closure, or if a panic occurs while dropping a value, or if
/// `DrainFilter` itself is leaked. /// the `DrainFilter` itself is leaked.
/// ///
/// # Examples /// # Examples
/// ///