pub trait ArrayNd<const DEPTH: usize>: Array {
type ItemNd;
const DIMENSIONS: [usize; DEPTH];
const FLAT_LENGTH: usize;
}
Expand description
A trait for N-dimensional arrays with depth up to 64.
The associated constants DIMENSIONS and FLAT_LENGTH vary depending on the chosen depth.
The assiciated type ItemNd represents the innermost type given a chosen depth.
§Examples
#![feature(generic_const_exprs)]
use array_trait::*;
type Mat2x3 = [[i8; 3]; 2];
/// The number of dimensions
const DEPTH: usize = 2;
// `FLAT_LENGTH` is the combined length if the N-dimensional array was flattened,
// i.e. the product of the lengths of each dimension.
assert_eq!(<Mat2x3 as ArrayNd<DEPTH>>::FLAT_LENGTH, 6);
// `DIMENSIONS` contains the lengths of each dimension ordered outermost to innermost.
assert_eq!(<Mat2x3 as ArrayNd<DEPTH>>::DIMENSIONS, [2, 3]);
Required Associated Constants§
Sourceconst DIMENSIONS: [usize; DEPTH]
const DIMENSIONS: [usize; DEPTH]
The dimensions of the n-dimensional containing the lengths of each level of array from outermost to innermost
Sourceconst FLAT_LENGTH: usize
const FLAT_LENGTH: usize
The product of the lengths of each dimension.
Required Associated Types§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.