bulks

Crates.iobulks
lib.rsbulks
version0.5.1
created_at2025-11-05 03:44:12.103781+00
updated_at2025-12-22 07:35:39.818638+00
descriptionAmazing bulks! They are like iterators, but in bulk, and therefore support collection into arrays.
homepage
repositoryhttps://github.com/sigurd4/bulks
max_upload_size
id1917377
size391,547
sigurd4 (sigurd4)

documentation

README

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)]);
Commit count: 0

cargo fmt