| ▲ | tcfhgj 15 hours ago | ||||||||||||||||
what about generics (equivalent to templates in C++), which allow compile time optimizations all the way down which may not possible if the implementation is hidden behind a void*? | |||||||||||||||||
| ▲ | OptionOfT 12 hours ago | parent [-] | ||||||||||||||||
Unless you use `dyn`, all code is monomorphized, and that code on its own will get optimized. This does come with code-bloat. So the Rust std sometimes exposes a generic function (which gets monomorphized), but internally passes it off to a non-generic function. This to avoid that the underlying code gets monomorphized. https://github.com/rust-lang/rust/blob/8c52f735abd1af9a73941... | |||||||||||||||||
| |||||||||||||||||