Crates.io | drain-while |
lib.rs | drain-while |
version | 0.1.0 |
source | src |
created_at | 2017-06-28 07:09:29.373889 |
updated_at | 2017-06-28 07:09:29.373889 |
description | A draining iterator which stops when a predicate becomes false |
homepage | |
repository | https://github.com/asayers/drain-while |
max_upload_size | |
id | 21074 |
size | 17,527 |
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]);
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.