Rust Traits, Generics, and dyn
Generics (including argument-position impl Trait) compile a copy of the function for each type it is called with and call it statically. dyn Trait compiles one function that reads the implementation’s address from a vtable. I treat the choice as depending on whether types must be mixed, and on whether the cost of extra copies or of indirect calls is the one that hurts. The fifth post in a Rust study series.