面试题答案
一键面试trait Animal {
fn speak(&self) {
println!("I am an animal");
}
}
struct Dog;
struct Cat;
impl Animal for Dog {}
impl Animal for Cat {
fn speak(&self) {
println!("Meow");
}
}
trait Animal {
fn speak(&self) {
println!("I am an animal");
}
}
struct Dog;
struct Cat;
impl Animal for Dog {}
impl Animal for Cat {
fn speak(&self) {
println!("Meow");
}
}