about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-05-04 18:11:49 -0400
committerGitHub <noreply@github.com>2025-05-04 18:11:49 -0400
commit760d8daaeacf53c39bb4738786a53aa32b3b7372 (patch)
treee308e137bafaf956161846ff8b320b4168904967
parentdf9f9ca99af3daae71586ba3d2a7449346404bba (diff)
parent5cbb27ff90b6685a27492dc2b1a23074e6194f9a (diff)
downloadrust-760d8daaeacf53c39bb4738786a53aa32b3b7372.tar.gz
rust-760d8daaeacf53c39bb4738786a53aa32b3b7372.zip
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`.
-rw-r--r--library/alloc/src/vec/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 65a83cb98ba..72279e12192 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -3659,9 +3659,9 @@ impl<T, A: Allocator> Vec<T, A> {
     ///
     /// If the returned `ExtractIf` 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.
+    /// Use [`retain_mut`] with a negated predicate if you do not need the returned iterator.
     ///
-    /// [`retain`]: Vec::retain
+    /// [`retain_mut`]: Vec::retain_mut
     ///
     /// Using this method is equivalent to the following code:
     ///