array_trait
A trait for any array, with item as an associated type, and length as an assiciated constant.
This crate is a subset of the crate array_ops
.
Examples
use *;
type Arr3 = ;
const A: Arr3 = ;
// The assiciated constant `LENGTH` equals the length of the array
assert_eq!;
assert_eq!;
use *;
type Arr3 = ;
const A: Arr3 = ;
/// The trait can be used in a function like this:
const const Array> where
: // This is required for now.
assert_eq!;
N-dimensional arrays
There is also a trait for N-dimensional arrays, which contain information on its inner structure, and supports a depth up to 64 dimensions.
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
use *;
type Mat2x3 = ;
/// 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!;
// `DIMENSIONS` contains the lengths of each dimension ordered outermost to innermost.
assert_eq!;
More operations
For more operations with arrays, using this as a basis, check out the crate array__ops.