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.
19 lines
856 B
19 lines
856 B
$ cargo run
|
|
Compiling traits-example v0.1.0 (file:///projects/traits-example)
|
|
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
|
|
--> src/main.rs:20:43
|
|
|
|
|
2 | fn baby_name() -> String;
|
|
| ------------------------- `Animal::baby_name` defined here
|
|
...
|
|
20 | println!("A baby dog is called a {}", Animal::baby_name());
|
|
| ^^^^^^^^^^^^^^^^^ cannot call associated function of trait
|
|
|
|
|
help: use the fully-qualified path to the only available implementation
|
|
|
|
|
20 | println!("A baby dog is called a {}", <::Dog as Animal>::baby_name());
|
|
| +++++++++ +
|
|
|
|
For more information about this error, try `rustc --explain E0790`.
|
|
error: could not compile `traits-example` due to previous error
|