diff options
| author | David Adler <adlerd@secundaverba.net> | 2017-09-12 22:33:27 -0700 |
|---|---|---|
| committer | David Adler <adlerd@secundaverba.net> | 2017-09-12 22:47:45 -0700 |
| commit | 518bd3085413670d3f7ccbc77abb64a0cb4a198a (patch) | |
| tree | 7c53351b9f048f05dc71d6268eb7b30fda63ff00 /src/liballoc | |
| parent | 2fdccaffe632e316c43224d0fae6fba903333aa3 (diff) | |
| download | rust-518bd3085413670d3f7ccbc77abb64a0cb4a198a.tar.gz rust-518bd3085413670d3f7ccbc77abb64a0cb4a198a.zip | |
Fix drain_filter doctest.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/vec.rs | 9 |
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, |
