Thanks to visit codestin.com
Credit goes to lib.rs

#iterator #array-iterator #iterate #collect #no-alloc

nightly no-std bulks

Amazing bulks! They are like iterators, but in bulk, and therefore support collection into arrays

21 releases (4 breaking)

Uses new Rust 2024

new 0.5.1 Dec 22, 2025
0.5.0 Dec 22, 2025
0.4.5 Dec 21, 2025
0.3.3 Nov 21, 2025
0.1.5 Nov 6, 2025

#862 in Rust patterns

23 downloads per month
Used in linspace

MIT license

380KB
10K SLoC

Build Status (nightly) Build Status (nightly, all features)

Build Status (stable) Build Status (stable, all features)

Test Status Lint Status

Latest Version License:MIT Documentation Coverage Status

bulks

This crate adds Bulks, which are similar to iterators, except they are stricter. They can only be wholly consumed, where every value is operated on in bulk. This, unlike with classic Iterators, makes them fully compatible with arrays!

Their constrained nature means fewer iterator-like operations are possible, but the guarantees it gives makes it possible to use them with arrays while still retaining the array's length. Operations that preserves the length of the data like map, zip, enumerate, rev and inspect are possible. Some other length-modifying operations are also possible with Bulks as long as the length is modified in a predetermined way, like with flat_map, flatten, intersperse, array_chunks and map_windows.

Any Bulk that was created from an array can be collected back into an array, given that the operations done on it makes the length predetermined at compile-time. Bulks can also be used with other structures, allowing generic implementations that will work on arrays as well as other iterables.

Example

use bulks::*;

let a = [1, 2, 3];

let b: [_; _] = a.bulk()
    .copied()
    .map(|x| (x - 1) as usize)
    .enumerate()
    .inspect(|(i, x)| assert_eq!(i, x))
    .collect();

assert_eq!(b, [(0, 0), (1, 1), (2, 2)]);

Dependencies

~315–730KB
~16K SLoC