In the Cat type, it shows that the method make_noise is implemented via a trait, however, the code errors because it can't find make_noise in the Cat type in the scope.
Is there any way to fix this issue while keeping the Pet trait?
src/pet.rs
trait Pet {
fn make_noise(&self) -> ();
}
pub struct Cat {
pub name: String,
pub age: i64
}
impl Pet for Cat {
fn make_noise(&self) -> () {
println!("Meow!");
}
}
src/main.rs
mod pet;
use pet::{Cat};
fn main() {
let fluffy = Cat {
name: String::from("Fluffy"),
age: 5
};
fluffy.make_noise();
}