remove drain-on-drop behavior from vec::DrainFilter and add #[must_use]
This commit is contained in:
parent
fa8762b7b6
commit
c0df1c8c43
6 changed files with 32 additions and 131 deletions
|
@ -2892,6 +2892,12 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
/// If the closure returns false, the element will remain in the vector and will not be yielded
|
||||
/// by the iterator.
|
||||
///
|
||||
/// If the returned `DrainFilter` is not exhausted, e.g. because it is dropped without iterating
|
||||
/// or the iteration short-circuits, then the remaining elements will be retained.
|
||||
/// Use [`retain`] with a negated predicate if you do not need the returned iterator.
|
||||
///
|
||||
/// [`retain`]: Vec::retain
|
||||
///
|
||||
/// Using this method is equivalent to the following code:
|
||||
///
|
||||
/// ```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue