1
Fork 0
No description
Find a file
2026-03-30 13:56:35 +02:00
examples Inline the field arrays 2026-03-28 21:15:53 +01:00
src workaround for rustc bug: a proper bound is necessary instead of an empty one 2026-03-30 13:56:35 +02:00
tests workaround for rustc bug: a proper bound is necessary instead of an empty one 2026-03-30 13:56:35 +02:00
.gitignore it kinda works i guess 2025-05-08 16:58:35 +02:00
Cargo.lock chore: Release multi-array-list version 0.2.1 2026-03-30 13:46:08 +02:00
Cargo.toml chore: Release multi-array-list version 0.2.1 2026-03-30 13:46:08 +02:00
LICENSE Top-level docs 2025-05-09 19:46:29 +02:00
README.md workaround for rustc bug: a proper bound is necessary instead of an empty one 2026-03-30 13:56:35 +02:00
rust-toolchain.toml This is now nightly only 2026-02-13 10:24:33 +01:00

MultiArrayList

Experimental: Only a small subset of the array list API is implemented.


A MultiArrayList stores a list of a struct.

Instead of storing a single list of items, MultiArrayList stores separate lists for each field of the struct. This allows for memory savings if the struct has padding, and also improves cache usage if only some fields are needed for a computation.

The primary API for accessing fields is the [items::<NAME>()][MultiArrayList::items()] function.


inspired by Zig's MultiArrayList.

Example

use multi_array_list::MultiArrayList;

struct Pizza {
    radius: u32,
    toppings: Vec<Topping>,
}

enum Topping {
    Tomato,
    Mozzarella,
    Anchovies,
}

let mut order = MultiArrayList::<Pizza>::new();

let margherita = Pizza {
    radius: 12,
    toppings: vec![Topping::Tomato],
};
order.push(margherita);

let napoli = Pizza {
    radius: 12,
    toppings: vec![Topping::Tomato, Topping::Anchovies],
};
order.push(napoli);

for topping in order.items_mut::<"toppings", Vec<Topping>>() {
    topping.push(Topping::Mozzarella);
}

License

MIT. See LICENSE.