Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BTreeSet::drain_filter documentation #86789

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,18 +941,20 @@ impl<T> BTreeSet<T> {
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 false, the value will remain in the list and will not be yielded
/// by the iterator.
/// If the closure returns `true`, the value is removed from the set and yielded. If
/// the closure returns `false`, or panics, the value remains in the set and will
/// not be yielded.
///
/// If the iterator is only partially consumed or not consumed at all, each of the remaining
/// values will still be subjected to the closure and removed and dropped if it returns true.
/// If the iterator is only partially consumed or not consumed at all, each of the
/// 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
/// if a panic occurs in the closure, or if a panic occurs while dropping a value, or if the
/// `DrainFilter` itself is leaked.
/// It is unspecified how many more values will be subjected to the closure if a
/// panic occurs in the closure, or if a panic occurs while dropping a value, or if
/// the `DrainFilter` itself is leaked.
///
/// # Examples
///
Expand Down