arr 0.4.0

A heap based fixed-sized array
Documentation

arr is a simple array crate designed to allow huge array allocation without stack overflows.

Even in rustc 1.44 allocating arrays too large to fit on the stack (say 8MB in size) will stack overflow even if the array is Boxed.

Basic usage:

use arr::Array;
// zero - fast allocation
let big_array: Array<u8> = Array::zero(1 << 25);
// default - slow allocation
let big_array2: Array<u8> = Array::new(1 << 25);
// template
let template = 10u8;
let big_array3: Array<u8> = Array::new_from_template(1 << 25, &template);

// Also works for 2d arrays (note even the sub-array would ordinarily blow stack)
let big_2d_array: Array<[u8; 1 << 25]> = Array::zero(4);

Try to do this with a traditional array:

let big_array: Box<[u8; 1 << 25]> = Box::new([0u8; 1 << 25]);

Currently the array supports two modes of allocation, via new (requires types to have Default + Copy) and new_from_template, only requiring clone. As long as this type fits on the stack and the array fits in memory this should be allocatable.