mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
449 B
35 lines
449 B
trait Pilot {
|
|
fn fly(&self);
|
|
}
|
|
|
|
trait Wizard {
|
|
fn fly(&self);
|
|
}
|
|
|
|
struct Human;
|
|
|
|
impl Pilot for Human {
|
|
fn fly(&self) {
|
|
println!("This is your captain speaking.");
|
|
}
|
|
}
|
|
|
|
impl Wizard for Human {
|
|
fn fly(&self) {
|
|
println!("Up!");
|
|
}
|
|
}
|
|
|
|
impl Human {
|
|
fn fly(&self) {
|
|
println!("*waving arms furiously*");
|
|
}
|
|
}
|
|
|
|
// ANCHOR: here
|
|
fn main() {
|
|
let person = Human;
|
|
person.fly();
|
|
}
|
|
// ANCHOR_END: here
|