How can I simplify this code? I still can't wrap my head around rust's traits and structs after OOP.
struct Player {
entity: Entity,
hp: i32,
atk: i32
}
struct Chest {
entity: Entity,
amount: i32
}
impl Drawable for Chest {
fn draw(&self, mut pencil: Pencil) {
pencil.draw(&self.entity);
}
}
impl Drawable for Player {
fn draw(&self, mut pencil: Pencil) {
pencil.draw(&self.entity);
}
}
Maybe there is a way to inherit some fields like in OOP?
Also, if anybody knows a good and clear tutorial about traits and structs in rust, I would be very glad if you shared it!