Closed eschorn1 closed 11 months ago
If by non-standard you mean a constant value not already provided in the typenum
crate, then you'll have to define it yourself:
use generic_array::{typenum::*, ArrayLength, GenericArray};
struct Foo<T, N: ArrayLength> {
data: GenericArray<T, N>,
}
// https://docs.rs/typenum/latest/typenum/operator_aliases/type.Prod.html
type U12345 = Prod<U15, U823>;
let foo = Foo::<i32, U12345> {
data: GenericArray::default(),
};
Though do be aware that very large arrays have the potential to overflow the stack when creating them. That's not exactly a generic-array
issue, just how Rust handles things, but can be made worse in debug builds.
Ah, excellent, thanks! ( I thought I had tried this ; ) much appreciated.
After studying the documentation and code, it remains unclear to me how to instantiate a non-standard size array (such as 12345 below). I suspect it may not be doable at this point, but wanted to ask directly.
Thank you!