I want an owned list of Rust trait objects. I could implement it as Vec<Box<dyn Trait>> but that allocates space on the heap for every trait object. What I’d prefer is a CompactList<dyn Trait> type with a memory representation that looks like:
[vtable1, size1, data1, vtable2, size2, data2, vtable3, size3, data3]
size* is the size in bytes of the corresponding data*.
With this, I could create an Iterator<Item = &dyn Trait>. The only operations I need on CompactList<T> are push() and iter().