[Idea] Type erasure in Rust through parametricity

This is a proposal for guaranteed type erasure. This is important: it’s not merely an optimization: if you can guarantee type erasure it opens the possibility for things that aren’t even expressible in Rust today – generics in trait objects being the most obvious example, higher-ranked function pointers being another.

The name “vtable” here is only to help the reader understand what’s going on, not to suggest any kind of automatic generation of vtables. They are definitely not traits, just plain old data structures that you can carry around and do whatever you please. In fact this offers more flexibility than mere traits, at the cost of being more awkward to use.

At this point, it’s quite moot to talk about ergonomics since none of this is even expressible in Rust. The proposal strives to make as few changes to the existing language as possible.