Improve E0599 explanation

This commit is contained in:
Guillaume Gomez 2020-05-20 12:02:52 +02:00
parent 97f3eeec82
commit e9ae64cca7

View file

@ -9,3 +9,18 @@ let x = Mouth;
x.chocolate(); // error: no method named `chocolate` found for type `Mouth`
// in the current scope
```
In this case, you need to implement the `chocolate` method to fix the error:
```
struct Mouth;
impl Mouth {
fn chocolate(&self) { // We implement the `chocolate` method here.
println!("Hmmm! I love chocolate!");
}
}
let x = Mouth;
x.chocolate(); // ok!
```