7 releases (2 stable)
Uses old Rust 2015
1.0.1 | Jul 30, 2016 |
---|---|
0.2.4 | Jun 28, 2016 |
#4 in #exhaustive
24 downloads per month
Used in 2 crates
(via tile_net)
6KB
140 lines
interleave-rs
Interleave is a macro that allows you to create an iterator that interleaves its input iterators.
The reason for making this library is because Itertools only has binary interleaving.
Behaviour
All iterators are exhausted (return None) before the interleaver will return None.
lib.rs
:
This crate allows you to create an arbitrary interleaving iterator. Each iterator is guaranteed to be behind the most advanced iterator by at max one next() call. The interleave macro is of arbitrary arity.
#[macro_use]
extern crate interleave;
fn main() {
use interleave::{IterList, MultiIter};
let iter = interleave!(1..5, 9..12, -3..2);
for i in iter {
println!("{:?}", i);
}
}
The types returned by the iterator can also be forced:
#[macro_use]
extern crate interleave;
fn main() {
use interleave::{IterList, MultiIter};
let iter = interleave!(i8; 1..5, 9..12, -3..2);
for i in iter {
println!("{:?}", i);
}
}
Most information can be found in the examples or the test module.
Dependencies
~0–700KB
~20K SLoC