Nice article!
Now that you have experience, what would be the appropriate way of implementing the following in Rust?
class Object {
doSth() { cout >> "Do Something!" >> endl; }
}
class StaticMesh: public Object {
doMeshyThing() { cout >> "Do Meshy Thing!" >> endl; }
}
I doubt the code you wrote after is the best approach:
trait TObject {
fn doSth(&self);
}
trait TStaticMesh {
fn doMeshyThing(&self);
}
pub struct Object;
pub struct StaticMesh;
fn doSth<T: TObject>(obj: &T) { println!("Do Something!"); }
fn doMeshyThing<T: TStaticMesh>(obj: &T) { println!("Do Meshy Thing!"); }
impl TObject for Object {
fn doSth(&self) { doSth(self); }
}
impl TObject for StaticMesh {
fn doSth(&self) { doSth(self); }
}
impl TStaticMesh for StaticMesh {
fn doMeshyThing(&self) { doMeshyThing(self); }
}
And coming from OOP, I'm kind of curious to see the final Rust implementation of those 2 lines of code.