Idea: auto for impl/dyn
Hi all, I don't yet know if this idea is stupid or not, maybe I'm just missing something.
What if we could specify kind of an "auto" where "impl" or "dyn" expected so we could let the compiler decide to use static dispatch or dynamic dispatch. The compiler knows more details on performance and at the same time, it knows how many actual types implement such trait.
For instance, in case of a method parameter it could decide to use static dispatch if there are only two types which could be used as arguments, but in case we add more types it could go dynamic to lower the memory footprint and achieve fewer cache misses.
Posted Jul 5, 2018, 11:54 AM UTC
35