2022-02-06 16:43:51 +08:00
|
|
|
$ cargo run
|
|
|
|
Compiling traits-example v0.1.0 (file:///projects/traits-example)
|
2023-01-16 17:34:52 +08:00
|
|
|
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
|
2022-02-06 16:43:51 +08:00
|
|
|
--> src/main.rs:20:43
|
|
|
|
|
|
2023-01-16 17:34:52 +08:00
|
|
|
2 | fn baby_name() -> String;
|
|
|
|
| ------------------------- `Animal::baby_name` defined here
|
|
|
|
...
|
2022-02-06 16:43:51 +08:00
|
|
|
20 | println!("A baby dog is called a {}", Animal::baby_name());
|
2024-06-06 21:23:21 +08:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
|
2022-02-06 16:43:51 +08:00
|
|
|
|
|
2023-01-16 17:34:52 +08:00
|
|
|
help: use the fully-qualified path to the only available implementation
|
|
|
|
|
|
2024-06-06 21:23:21 +08:00
|
|
|
20 | println!("A baby dog is called a {}", <Dog as Animal>::baby_name());
|
|
|
|
| +++++++ +
|
2022-02-06 16:43:51 +08:00
|
|
|
|
2023-01-16 17:34:52 +08:00
|
|
|
For more information about this error, try `rustc --explain E0790`.
|
2024-06-06 21:23:21 +08:00
|
|
|
error: could not compile `traits-example` (bin "traits-example") due to 1 previous error
|