iterchunks

Crates.io Version Docs.rs Latest Build Status

This crate provides an iterator adapter that yields N elements of the iterator at a time.

This methods provided here have the corresponding nightly APIs:

The nightly APIs handle remainders better and will likely have better performance, so they should be preferred if possible.

Getting started

Add the crate to your Cargo manifest.

sh cargo add iterchunks

And bring the IterArrayChunks trait into scope.

rust use iterchunks::IterArrayChunks;

Now you can use the [array_chunks] method on any iterator.

rust for [a, b, c] in iter.array_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.array_chunks::<3>();

License

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.