generic-array 0.6.0

Generic types implementing functionality of arrays
Documentation

This crate implements a structure that can be used as a generic array type.use 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 generic_array::{ArrayLength, GenericArray};
struct Foo<T, N: ArrayLength<T>> {
    data: GenericArray<T,N>
}

The ArrayLength<T> trait is implemented by default for unsigned integer types from typenum.

For ease of use, an arr! macro is provided - example below:

# #[macro_use]
# extern crate generic_array;
# extern crate typenum;
# fn main() {
let array = arr![u32; 1, 2, 3];
assert_eq!(array[2], 3);
# }