this post was submitted on 14 Nov 2022
7 points (81.8% liked)

Rust Programming

8438 readers
38 users here now

founded 5 years ago
MODERATORS
 

Just sharing from r/rust

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 7 points 2 years ago (1 children)

@kixik Inheritance can always be substituted by composition which is what #Rust does pretty well. Constexpr isn't on C++ level, but I guess you can generate code from build script so there's ways around it.
As for virtual functions - Traits are effectively to virtual function lookup table declarations that get used by dyn SomeTrait type. So calling a fn on Box\<dyn T\> generates VMT lookup.

[โ€“] [email protected] 6 points 2 years ago

@kixik Thanks to good macro system Rust can (via enum_dispatch) transform those lookups into a switch statement which is best of both worlds IMO.