Is it possible to tell the compiler that I want a trait object that is Sized to accommodate a known set of structs implementing the Trait?
That is, if I have a public factory function for instantiating a
Something and I have two different private somethings that implement the
BarSomething and I don’t want heap allocation (i.e. I don’t want the factory to return
Box<Something>, can I make
Something a trait and tell the compiler that the trait objects should be Sized to accommodate the larger of
Or do I need to make
Something a struct that has an
enum member that is a tagged union of
BarSomething with manually-written dispatch that matches on the enum?