#no-std #iterator #chunks

iterchunks

An iterator adapter to adapter that yields N elements of the iterator at a time

5 unstable releases

0.3.0 Dec 4, 2022
0.2.0 Dec 1, 2022
0.1.2 Nov 29, 2022
0.1.1 Nov 28, 2022
0.1.0 Nov 27, 2022

#8 in #chunks

Download history 8/week @ 2023-06-11 20/week @ 2023-06-18 20/week @ 2023-06-25 22/week @ 2023-07-02 14/week @ 2023-07-09 15/week @ 2023-07-16 17/week @ 2023-07-23 7/week @ 2023-07-30 13/week @ 2023-08-06 39/week @ 2023-08-13 86/week @ 2023-08-20 20/week @ 2023-08-27 45/week @ 2023-09-03 41/week @ 2023-09-10 32/week @ 2023-09-17 19/week @ 2023-09-24

139 downloads per month
Used in itermore

MIT/Apache

17KB
136 lines

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.

cargo add iterchunks

And bring the IterArrayChunks trait into scope.

use iterchunks::IterArrayChunks;

Now you can use the array_chunks method on any iterator.

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.

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.

Dependencies