| ▲ | zadikian 5 hours ago | |
It doesn't seem uncommon for someone to generally like Rust but still want to use something OO for UI. I'm in that boat. Never liked OOP much, but it makes sense sometimes. | ||
| ▲ | antonvs 44 minutes ago | parent [-] | |
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. | ||