The arr crate provides a single fixed-sized array data-structure that is purely heap-based.
Include:
[dependencies]
arr = "0.6.0"
Basic usage:
use arr::Array;
// Allocate a 16MB chunk of zeros as 16 byte sub-arrays
let huge_array: Array<[u8; 16]> = Array::zero(1 << 20);
println!("{}", huge_array.len());
The motivation for this crate comes from the limitation of rust to easily allocate heap-based arrays without blowing the stack.
This likely will blow your stack:
let huge_array: [[u8; 16]; 1 << 20] = [[0u8; 16]; 1 << 20];