2 ms·
In Rust, type classes do not have to carrry that overhead; when you use them as a trait bound, you get monomirphized code. When you use them as a trait object,
by steveklabnik 8y ago
In Rust, type classes do not have to carrry that overhead; when you use them as a trait bound, you get monomirphized code. When you use them as a trait object, you do carry the vtable around.
For other languages, you may be correct in all cases.
- kibwen 8y agoAnd it's worth mentioning that the "trait object" form of generics is relatively rare in Rust code; there's a fair amount of friction to using them that makes them somewhat of a beginner hurdle considering how easy they are to reach for (which the future `dyn` keyword intends to rectify).