Enum for all variations of a const generic struct

1k Views Asked by At

With const generics almost here I was wondering how would one build an enum for all (or at least for many) possible variations of a const generic struct? Or if that's not possible, how would one crate a vector that's capable of containing multiple variations of the const generic struct without dynamic access?

Example code: (pseudo code)

pub struct Test<const L: usize> {
    data: [i32; L]
}

pub enum AllVariations {
    Test1(Test<1>),
    Test2(Test<2>),
    Test3(Test<3>),
    .
    .
    .
}

To clarify, with dynamic access I mean

pub trait TraitForTestType {}

and doing

let v: Vec<Box<dyn TraitForTestType>> = Vec::new();
0

There are 0 best solutions below