Oh please not. Spare us from the C++ type-polymorphy nightmare. Traits are so much better than inheritance.
deleted by creator
It’s an opinion, but it doesn’t mean that it’s necessary an objectively correct one. It’s true that Rust has had to rethink how GUI’s have traditionally been done. It’s not an OO language and it never will be. But there are emerging frameworks that do the job quite elegantly. They just don’t do it like a C++ developer would expect, and he has extremely extensive C++ experience.
It might could learn from some recent experiments in Go GUIs. GIO is an immediate mode GUI that’s unusual.
https://golang.ch/the-ultimate-list-of-golang-gui-graphics-image-related-libraries/?amp=1
Seems there’s been a bit more experimentation in this area than there has under Rust.
@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 bydyn SomeTrait
type. So calling a fn onBox\<dyn T\>
generates VMT lookup.@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.