| ▲ | antonvs 2 hours ago | |
What OO features are you thinking of that Rust doesn't have? Traits give you the ability to model typical GUI OO hierarchies, e.g.:
Implementation inheritance can be achieved with good old shared functions that take trait arguments, like this:
You can also define default methods at the trait level.This all ends up being much more precise, clear, and strongly typed than the typical OO inheritance model, while still following a similar overall structure. You can see real world examples of this kind of thing in the various GUI toolkits for Rust, like Iced, gpui, egui, Dioxus, etc. | ||