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