about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul Mabileau <paul.mabileau@harfanglab.fr>2025-05-17 02:36:08 +0200
committerPaul Mabileau <paul.mabileau@harfanglab.fr>2025-05-17 02:36:08 +0200
commit9205ee27a815e5b356cfce6269d9ded1d1c098f7 (patch)
tree1a25d21812ecd6a072dd4bce80c18077407e6528
parent35f847363729b16332eab1a85900617218495757 (diff)
downloadrust-9205ee27a815e5b356cfce6269d9ded1d1c098f7.tar.gz
rust-9205ee27a815e5b356cfce6269d9ded1d1c098f7.zip
Docs(lib/extract_if): Unify paragraph about closure actions
Also fixes `HashSet`'s that incorrectly designated itself as a `list`.

Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
-rw-r--r--library/alloc/src/collections/linked_list.rs6
-rw-r--r--library/alloc/src/vec/mod.rs6
-rw-r--r--library/std/src/collections/hash/map.rs6
-rw-r--r--library/std/src/collections/hash/set.rs6
4 files changed, 12 insertions, 12 deletions
diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs
index 00e2805d11f..1890a114d3c 100644
--- a/library/alloc/src/collections/linked_list.rs
+++ b/library/alloc/src/collections/linked_list.rs
@@ -1124,9 +1124,9 @@ impl<T, A: Allocator> LinkedList<T, A> {
 
     /// Creates an iterator which uses a closure to determine if an element should be removed.
     ///
-    /// If the closure returns true, then the element is removed and yielded.
-    /// If the closure returns false, the element will remain in the list and will not be yielded
-    /// by the iterator.
+    /// If the closure returns `true`, the element is removed from the list and
+    /// yielded. If the closure returns `false`, or panics, the element remains
+    /// in the list and will not be yielded.
     ///
     /// 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.
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 4d03ca63ec8..e5f2c9468e3 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -3650,9 +3650,9 @@ impl<T, A: Allocator> Vec<T, A> {
 
     /// Creates an iterator which uses a closure to determine if an element in the range should be removed.
     ///
-    /// If the closure returns true, then the element is removed and yielded.
-    /// If the closure returns false, the element will remain in the vector and will not be yielded
-    /// by the iterator.
+    /// If the closure returns `true`, the element is removed from the vector
+    /// and yielded. If the closure returns `false`, or panics, the element
+    /// remains in the vector and will not be yielded.
     ///
     /// Only elements that fall in the provided range are considered for extraction, but any elements
     /// after the range will still have to be moved if any element has been extracted.
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
index 3530f890f52..9732d2c2d5c 100644
--- a/library/std/src/collections/hash/map.rs
+++ b/library/std/src/collections/hash/map.rs
@@ -650,9 +650,9 @@ impl<K, V, S> HashMap<K, V, S> {
 
     /// Creates an iterator which uses a closure to determine if an element should be removed.
     ///
-    /// If the closure returns true, the element is removed from the map and yielded.
-    /// If the closure returns false, or panics, the element remains in the map and will not be
-    /// yielded.
+    /// If the closure returns `true`, the element is removed from the map and
+    /// yielded. If the closure returns `false`, or panics, the element remains
+    /// in the map and will not be yielded.
     ///
     /// Note that `extract_if` lets you mutate every value in the filter closure, regardless of
     /// whether you choose to keep or remove it.
diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs
index 5043d1bd1df..482d57b47f6 100644
--- a/library/std/src/collections/hash/set.rs
+++ b/library/std/src/collections/hash/set.rs
@@ -278,9 +278,9 @@ impl<T, S> HashSet<T, S> {
 
     /// Creates an iterator which uses a closure to determine if an element should be removed.
     ///
-    /// If the closure returns true, then the element is removed and yielded.
-    /// If the closure returns false, the element will remain in the list and will not be yielded
-    /// by the iterator.
+    /// If the closure returns `true`, the element is removed from the set and
+    /// yielded. If the closure returns `false`, or panics, the element remains
+    /// in the set and will not be yielded.
     ///
     /// 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.