I increasingly find myself using [&dyn Trait]
slices for "lists" of heterogenous types.
As const generics continue to mature, lately I've been wondering if these same cases could be handled monomorphically by combining const generics with impl Trait
.
Instead of the receiver of such an argument operating over a slice, it could be an array of const generic size, where the specific types used by the caller, index-by-index, are all known by the compiler, but the receiver sees only impl Trait
for each member.
Is there already some exploration of this general idea in an existing document/issue I may have missed?