Exactly. The functions of the super trait are also required when implementing the child trait's functions, as you would expect from inheritance.
livingcoder
Basically, you can generalize your trait types into their parent (super) traits for situations when functionality is specific to those supertrait objects.
As an example, if you have a trait CanBark and it is a super trait for the trait IsDog, you can coerce your references of &dyn IsDog into a &dyn CanBark. You can then work with other trait types that share a super trait.
trait CanBark {
fn bark(&self);
}
trait IsSeal: CanBark { }
trait IsDog: CanBark { }
fn bark_as_group(barkers: &Vec<&dyn CanBark>) {
for barker in barkers {
barker.bark();
}
}
let spot: &dyn IsDog = get_spot();
let seal: &dyn IsSeal = get_seal();
let barkers: Vec<&dyn CanBark> = Vec::new();
barkers.push(spot); // coerced
barkers.push(seal); // coerced
bark_as_group(&barkers);
At least, I hope this is possible now. If it's purely "you can return a coerced type from a function", that is less useful.
I think this prediction will age extremely well if we last that long. That's a very big "if".
Wow, that trait feature is great. I've been eagerly waiting for that one for a long time. Thank you to everyone who made that possible.
When I learned Python I thought that not having a statically typed language was the way to go, but then it just became an issue when I was trying to ensure that everything was at least something like what I was expecting. Going back to statically typed languages even harder with Rust has been a dream. I love it.
I kept most of my bindings the same as the normal QWERTY keyboard, so I don't have much of an issue swapping between them. I had debated a lot about changing to other keyboard layouts and I'm really glad that I didn't.
I love my Moonlander. I'll never go back.
I've found that one of the best things to do when making a library for something that is going to have a web interface is to first have it work in the terminal. You can much more quickly play around with the design and fix issues there instead of having to work with a more complex web interface.
You just create a simple menu system, like input("1: Feature A\n2: Feature B\n>")
and just start trying out all of the different scenarios and workflows.
I had a coworker who would sometimes not create a method as being static to the class and would therefore need to create a default instance to call said method. "It's domain-driven design."
The price and quality are so hard to beat.
Sounds good. Please share what you find and what you end up going with.
I leave mine in the trunk and have only walked into the store without them twice. Not forgetting them before walking into the store and putting them back into the trunk after unloading them is the hardest part.