]> git.lizzy.rs Git - rust.git/commitdiff
Improve E0599 explanation
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Wed, 20 May 2020 10:02:52 +0000 (12:02 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Wed, 20 May 2020 10:03:24 +0000 (12:03 +0200)
src/librustc_error_codes/error_codes/E0599.md

index c44e60571e1e3dd9966eb979df04c33736a4d285..5b1590b29998f489c07b8e6af17b3f5434b3c1c2 100644 (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!
+```