Skip to content

Commit 3b2ad49

Browse files
committed
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 f0b8166. In particular, this explicitly documents the iteration order.
1 parent 64de497 commit 3b2ad49

File tree

1 file changed

+11
-9
lines changed
  • library/alloc/src/collections/btree

1 file changed

+11
-9
lines changed

library/alloc/src/collections/btree/set.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -941,18 +941,20 @@ impl<T> BTreeSet<T> {
941941
BTreeSet { map: self.map.split_off(key) }
942942
}
943943

944-
/// Creates an iterator which uses a closure to determine if a value should be removed.
944+
/// Creates an iterator that visits all values in ascending order and uses a closure
945+
/// to determine if a value should be removed.
945946
///
946-
/// If the closure returns true, then the value is removed and yielded.
947-
/// If the closure returns false, the value will remain in the list and will not be yielded
948-
/// by the iterator.
947+
/// If the closure returns `true`, the value is removed from the set and yielded. If
948+
/// the closure returns `false`, or panics, the value remains in the set and will
949+
/// not be yielded.
949950
///
950-
/// If the iterator is only partially consumed or not consumed at all, each of the remaining
951-
/// values will still be subjected to the closure and removed and dropped if it returns true.
951+
/// If the iterator is only partially consumed or not consumed at all, each of the
952+
/// remaining values is still subjected to the closure and removed and dropped if it
953+
/// returns `true`.
952954
///
953-
/// It is unspecified how many more values will be subjected to the closure
954-
/// if a panic occurs in the closure, or if a panic occurs while dropping a value, or if the
955-
/// `DrainFilter` itself is leaked.
955+
/// It is unspecified how many more values will be subjected to the closure if a
956+
/// panic occurs in the closure, or if a panic occurs while dropping a value, or if
957+
/// the `DrainFilter` itself is leaked.
956958
///
957959
/// # Examples
958960
///

0 commit comments

Comments
 (0)