1
Fork 0

remove drain-on-drop behavior from vec::DrainFilter and add #[must_use]

This commit is contained in:
The 8472 2022-11-15 19:50:11 +01:00
parent fa8762b7b6
commit c0df1c8c43
6 changed files with 32 additions and 131 deletions

View file

@ -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:
///
/// ```