3 ms·
I mean if you know all the concrete types ahead of time you can put them in an enum. It kind of makes me we wish there was a keyword that would grab all implem
by charrondev 2y ago
I mean if you know all the concrete types ahead of time you can put them in an enum.
It kind of makes me we wish there was a keyword that would grab all implementations of that trait being compiled and do the same thing though. At least for a statically linked codebase it could figure out all the sizes of the implementations
- josephg 2y agoThat would be lovely, but it would give you “spooky action at a distance” where some large struct adding an impl for some trait would change the size of a data structure in another unrelated part of the program. But it would be nice if there was some unification of the idea of an enum where every variant implements a trait and &dyn Trait. Basically, an enum made up of a set of named structs where each struct implements a specific trait could be a lovely concept.