Expand description
This library provides a draining Iterator
which stops when a predicate becomes false.
use drain_while::*;
let mut original = vec![1,2,3,4,5];
let mut matching = vec![];
for x in original.drain_while(|x| *x < 3) {
matching.push(x);
}
assert_eq!(matching, vec![1,2]);
assert_eq!(original, vec![3,4,5]);
See the documentation for drain_while()
for
more.
Structs§
- Drain
While - A draining iterator for
Vec<T>
.