5 ms·
Like many compiled languages, Rust does dead code elimination on everything.
by steveklabnik 1y ago
Like many compiled languages, Rust does dead code elimination on everything.
- iainmerrick 1y agoRight, but it depends on how the code is written, right? If you use mostly free functions things will shake out naturally, if you use lots of dynamic dispatch you'll pull in stuff that doesn't get called.
- steveklabnik 1y agoRust does static dispatch even for non-free functions. Only trait objects are dynamically dispatched, and most people argue they’re under-used in Rust, not overused. If that does become a problem, there are also techniques like https://github.com/rust-lang/rust/issues/68262 https://github.com/rust-lang/rust/issues/68262 too.