Crate generic_array
This crate implements a structure that can be used as a generic array type.
Core Rust array types [T; N] can't be used generically with
respect to N, so for example this:
struct Foo<T, N> {
data: [T; N]
}
won't work.
generic-array exports a GenericArray<T,N> type, which lets
the above be implemented as:
use ;
The ArrayLength<T> trait is implemented by default for
unsigned integer types from
typenum:
# use ;
use U5;
#
For example, GenericArray<T, U5> would work almost like [T; 5]:
# use ;
use U5;
#
For ease of use, an arr! macro is provided - example below:
#
# extern crate generic_array;
# extern crate typenum;
#
Modules
-
arr
Implementation for
arr!macro. - functional Functional programming with generic sequences
-
iter
GenericArrayiterator implementation. -
sequence
Useful traits for manipulating sequences of data stored in
GenericArrays - typenum
Structs
-
GenericArray
Struct representing a generic array -
GenericArray<T, N>works like [T; N] -
GenericArrayIter
An iterator that moves out of a
GenericArray
Traits
-
ArrayLength
Trait making
GenericArraywork, marking types to be used as length of an array
Macros
-
arr
Macro allowing for easy generation of Generic Arrays.
Example:
let test = arr![u32; 1, 2, 3];