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.
This commit is contained in:
commit
daf4f34fe3
1 changed files with 3 additions and 3 deletions
|
@ -1470,11 +1470,11 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
///
|
||||
/// ```
|
||||
/// let mut vec = vec![1, 2, 3, 4];
|
||||
/// vec.retain_mut(|x| if *x > 3 {
|
||||
/// false
|
||||
/// } else {
|
||||
/// vec.retain_mut(|x| if *x <= 3 {
|
||||
/// *x += 1;
|
||||
/// true
|
||||
/// } else {
|
||||
/// false
|
||||
/// });
|
||||
/// assert_eq!(vec, [2, 3, 4]);
|
||||
/// ```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue