1 unstable release

Uses old Rust 2015

0.1.0 Aug 28, 2016

#1907 in Rust patterns

Download history 3618/week @ 2024-07-22 4853/week @ 2024-07-29 3779/week @ 2024-08-05 2861/week @ 2024-08-12 4735/week @ 2024-08-19 3250/week @ 2024-08-26 3467/week @ 2024-09-02 3876/week @ 2024-09-09 3353/week @ 2024-09-16 3692/week @ 2024-09-23 2789/week @ 2024-09-30 3222/week @ 2024-10-07 3645/week @ 2024-10-14 3516/week @ 2024-10-21 2510/week @ 2024-10-28 4418/week @ 2024-11-04

14,120 downloads per month
Used in 5 crates (3 directly)

MIT license

6KB
112 lines

split-iter Build Status

Provides the trait Splittable, which allows you to split an iterator according to a predicate.

Documentation

Usage

Add to your Cargo.toml:

[dependencies]
split-iter = "0.1"

Example

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]);
}

lib.rs:

Provides the trait Splittable, which allows you to split an iterator according to a predicate.

Example

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]);
}

No runtime deps