Crate static_array
source ·Expand description
A crate providing statically sized, heap allocated arrays without requiring a copy from the stack for array creation.
Examples
Creating a large array on the heap using a function.
use static_array::HeapArray;
// Creates an array 16 MB (on 64 bit systems) in size which is larger than the standard linux stack size.
let array: HeapArray<usize, 2000000> = HeapArray::from_fn(|i| i);
assert_eq!(1247562, array[1247562]);
Creating a large array from the default value of a type.
use static_array::HeapArray;
let array: HeapArray<usize, 2000000> = HeapArray::default();
assert_eq!(0, array[1247562]);
Structs
- A heap allocated contiguous one dimensional array. This is equivalent in layout to the type
[T; N]
. - A heap allocated contiguous two dimensional array. This is equivalent to the type
[[T; M]; N]
. - A heap allocated contiguous three dimensional array. This is equivalent to the type
[[[T; L]; M]; N]
.