diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-05-25 04:00:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-25 04:00:56 +0200 |
| commit | 3338ff7dcf1b038887532648e49240f6f5a03d07 (patch) | |
| tree | 3f6b1126182ed9598635666da2fb58cf04984f17 /library/alloc/src/vec/mod.rs | |
| parent | 3f91bbcd5f67b91e9bad623baf9e480c86bdc38d (diff) | |
| parent | b1d7480acbc6bcc01f0eef98feaccdf53b387cd3 (diff) | |
Rollup merge of #141108 - PaulDance:fix-extract_if-docs, r=Mark-Simulacrum
Docs(lib): Fix `extract_if` docs Various fixes to the documentation comments of the several `extract_if` collection methods available. It originally started with a small typo fix in `Vec`'s spotted when reading the 1.87 release notes, but then by looking at the others' for comparison in order to try determining what was the intended sentence, some inconsistencies were spotted. Therefore, some other changes are also proposed here to reduce these avoidable differences, going more and more nit-picky along the way. See the individual commits for more details about each change. `@rustbot` label T-libs A-collections A-docs
Diffstat (limited to 'library/alloc/src/vec/mod.rs')
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 59879f23d78..ce7321544b6 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -3648,11 +3648,11 @@ impl<T, A: Allocator> Vec<T, A> { Splice { drain: self.drain(range), replace_with: replace_with.into_iter() } } - /// Creates an iterator which uses a closure to determine if element in the range should be removed. + /// 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. @@ -3692,8 +3692,8 @@ impl<T, A: Allocator> Vec<T, A> { /// But `extract_if` is easier to use. `extract_if` is also more efficient, /// because it can backshift the elements of the array in bulk. /// - /// Note that `extract_if` also lets you mutate the elements passed to the filter closure, - /// regardless of whether you choose to keep or remove them. + /// The iterator also lets you mutate the value of each element in the + /// closure, regardless of whether you choose to keep or remove it. /// /// # Panics /// @@ -3701,7 +3701,7 @@ impl<T, A: Allocator> Vec<T, A> { /// /// # Examples /// - /// Splitting an array into evens and odds, reusing the original allocation: + /// Splitting a vector into even and odd values, reusing the original vector: /// /// ``` /// let mut numbers = vec![1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 14, 15]; |
