Crates.io | split-iter |
lib.rs | split-iter |
version | 0.1.0 |
source | src |
created_at | 2016-08-28 21:28:59.768585 |
updated_at | 2016-08-28 21:28:59.768585 |
description | Allows splitting of iterators. |
homepage | |
repository | https://github.com/Mixthos/split-iter |
max_upload_size | |
id | 6162 |
size | 6,717 |
Provides the trait Splittable
, which allows you to split an iterator
according to a predicate
.
Add to your Cargo.toml:
[dependencies]
split-iter = "0.1"
extern crate split_iter;
use split_iter::Splittable;
fn main() {
let (odd, even) = (1..10).split(|v| v % 2 == 0);
assert_eq!(odd.collect::<Vec<_>>(), [1,3,5,7,9]);
assert_eq!(even.collect::<Vec<_>>(), [2,4,6,8]);
}