This crate provides an iterator adapter that yields N elements of the iterator at a time.
Add the crate to your Cargo manifest.
sh
cargo add iterchunks
And bring the IterChunks
trait into scope.
rust
use iterchunks::IterChunks;
Now you can use the chunks
method on any iterator.
rust
for [a, b, c] in iter.chunks() {
println!("{} {} {}", a, b, c)
}
Generally the size of N
can be inferred by the compiler but you can also
specify it manually.
rust
let c = iter.chunks::<3>();
This project is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.