This library provides ways to create and deal with multi-dimensional arrays.
It basically tries to generalize Box<[T]>
, &[T]
and &mut[T]
to multiple
dimensions with some convenient methods that allow you to slice views,
create lower-dimensional slices of it, subsampled or reversed views or
even swap dimensions (for example, to create a transposed view of a 2D
matrix).
Example
In the following example you'll see how a 3D array and two views into it (2D and 1D) can be created.
use *;
let mut voxels = new; // 3x4x5 ints
voxels = 1;
voxels = 23;
voxels = 42;
assert!;
let slice = voxels.eliminated_dim; // 2D slice
assert!;
let lane = slice.eliminated_dim; // 1D lane
assert!;
Here, slice
is a 2D slice of the 3D volume (at y=2) and lane
is a
one-dimensional view that also acts as an ExactSize/DoubleEnded iterator.