about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-05-20 19:54:40 +0200
committerGitHub <noreply@github.com>2022-05-20 19:54:40 +0200
commitdaf4f34fe34a3d7f4d6427b9b6926b39f83e2e50 (patch)
treee9316ad5c728697d256842010cc02b052a150725
parent76f662c963f54807d21b14f26823068c608a3128 (diff)
parent1a41a665cf4333696a44eacfa1d97180cc981185 (diff)
downloadrust-daf4f34fe34a3d7f4d6427b9b6926b39f83e2e50.tar.gz
rust-daf4f34fe34a3d7f4d6427b9b6926b39f83e2e50.zip
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.
-rw-r--r--library/alloc/src/vec/mod.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 3dc8a4fbba8..62bc04cadee 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -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]);
     /// ```