Skip to content

Commit 760d8da

Browse files
authored
Rollup merge of #140625 - paolobarbolini:vec-extract-if-alt-is-retain_mut, r=Mark-Simulacrum
Suggest `retain_mut` over `retain` as `Vec::extract_if` alternative The docs for `Vec::extract_if` suggest using `Vec::retain` if the user doesn't need the removed item. Given that `extract_if` gives a mutable reference to the evaluated element, `retain_mut` is the most appropriate alternative, not `retain`.
2 parents df9f9ca + 5cbb27f commit 760d8da

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/vec/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3659,9 +3659,9 @@ impl<T, A: Allocator> Vec<T, A> {
36593659
///
36603660
/// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating
36613661
/// or the iteration short-circuits, then the remaining elements will be retained.
3662-
/// Use [`retain`] with a negated predicate if you do not need the returned iterator.
3662+
/// Use [`retain_mut`] with a negated predicate if you do not need the returned iterator.
36633663
///
3664-
/// [`retain`]: Vec::retain
3664+
/// [`retain_mut`]: Vec::retain_mut
36653665
///
36663666
/// Using this method is equivalent to the following code:
36673667
///

0 commit comments

Comments
 (0)