Crate generic_array [−] [src]
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:
struct Foo<T, N: ArrayLength<T>> { data: GenericArray<T,N> }
The ArrayLength<T> trait is implemented by default for tuples consisting of binary structs _1 and _0, like ((_1, _0), _1).
This allows one to define length types as, for example, type _6 = ((_1, _1), _0).
Currently, the crate implements its own numeric types. This might change in the future.
Structs
| GenericArray |
Struct representing a generic array - GenericArray |
| GenericArrayImplEven |
Internal type used to generate a struct of appropriate size |
| GenericArrayImplOdd |
Internal type used to generate a struct of appropriate size |
| _0 |
Struct representing bit O |
| _1 |
Struct representing bit 1 |
Traits
| ArrayLength |
Trait making GenericArray work, marking types to be used as length of an array |
| Nat |
Nonnegative type-level integer, e.g., |