From 518bd3085413670d3f7ccbc77abb64a0cb4a198a Mon Sep 17 00:00:00 2001 From: David Adler Date: Tue, 12 Sep 2017 22:33:27 -0700 Subject: [PATCH] Fix drain_filter doctest. --- src/liballoc/vec.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 8141851b8c9af..caca401015698 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1969,16 +1969,19 @@ impl Vec { /// 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,