Expand description
This module contains several “hacky” utilities to work around the current lack of generic_const_exprs in Rust.
In several parts of the codebase we have to creates arrays whose length is determined by an associated constant of a trait. Seeing as this is impossible in stable Rust, we instead use the following pattern:
trait MyTrait {
type Weights: ArrayLike<usize, Elem = f64>;
}
struct MyStruct;
impl MyTrait for MyStruct {
type Weights = [f64; 10];
}This module also implements various utilities for serializing arbitrary length arrays.
The current version of serde hasn’t been able to do this as it breaks backwards
compatibility for zero length arrays.
Modules§
- vec
- Contains methods for working with vecs of arrays.
Structs§
- Array
Wrap - A wrapper around an
ArrayLikewhich implements several common traits depending on the elements ofI. This includesDefault,Clone,From, and serialization assuming the element type also satisfies those traits.
Traits§
- Array
Like - A helper trait for array types which can be indexed and iterated, with
compile time known length. Use of this trait can be removed if
generic_const_exprsis ever stabilized.
Functions§
- deserialize
- Deserialize const generic or arbitrarily-large arrays
- serialize