about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/liballoc/vec.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index 8141851b8c9..caca4010156 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -1969,16 +1969,19 @@ impl<T> Vec<T> {
     /// Using this method is equivalent to the following code:
     ///
     /// ```
-    /// # let some_predicate = |x: &mut i32| { *x == 2 };
-    /// # let mut vec = vec![1, 2, 3, 4, 5];
+    /// # let some_predicate = |x: &mut i32| { *x == 2 || *x == 3 || *x == 6 };
+    /// # let mut vec = vec![1, 2, 3, 4, 5, 6];
     /// let mut i = 0;
     /// while i != vec.len() {
     ///     if some_predicate(&mut vec[i]) {
     ///         let val = vec.remove(i);
     ///         // your code here
+    ///     } else {
+    ///         i += 1;
     ///     }
-    ///     i += 1;
     /// }
+    ///
+    /// # assert_eq!(vec, vec![1, 4, 5]);
     /// ```
     ///
     /// But `drain_filter` is easier to use. `drain_filter` is also more efficient,