Skip to content

Commit daf4f34

Browse files
authored
Rollup merge of #97187 - ajtribick:patch-1, r=thomcc
Reverse condition in Vec::retain_mut doctest I find that the doctest for `Vec::retain_mut` is easier to read and understand when the `if` block corresponds to the path that returns `true` and the `else` block returns `false`. Having the `if` block be the `false` path led me to stare at the example for somewhat longer than I probably had to.
2 parents 76f662c + 1a41a66 commit daf4f34

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/alloc/src/vec/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1470,11 +1470,11 @@ impl<T, A: Allocator> Vec<T, A> {
14701470
///
14711471
/// ```
14721472
/// let mut vec = vec![1, 2, 3, 4];
1473-
/// vec.retain_mut(|x| if *x > 3 {
1474-
/// false
1475-
/// } else {
1473+
/// vec.retain_mut(|x| if *x <= 3 {
14761474
/// *x += 1;
14771475
/// true
1476+
/// } else {
1477+
/// false
14781478
/// });
14791479
/// assert_eq!(vec, [2, 3, 4]);
14801480
/// ```

0 commit comments

Comments
 (0)