I know this probably gets asked a lot, but I am looking for a way to use some inheritance in Rust. I don't quite yet understand how to practically design with traits / implementations. I'm still interested in comparing its methodologies. In other words, what patterns or use cases does it intend for?
First of all, I love Rust. I've studied it quite a bit. I want to see it go places, and I agree and am impressed with the philosophy overall. I know at one point there was virtual inheritance features that have since been removed. I don't, however, believe in going so far as to say composition-over-inheritance means no inheritance at all. At least the principle behind "copy-on-write" belongs in some form, and liberates proper composition. I trust Rust ultimately will integrate something worthwhile.
Anyway, I just want to be able to have a tree of elements, each with their own methods (which are inherited from multiple layers.) I am experimenting now -- just not sure about the inheritance part.
I've seen syntax like this.
trait B : A { fn b(&self); }
but don't know what it does.
So, I have elements that need to have:
- methods of the same name with different behavior,
- which are inherited from multiple layers,
- but they also need to have some unique methods.