]>
Commit | Line | Data |
---|---|---|
60c5eb7d XL |
1 | A definition of a method not in the implemented trait was given in a trait |
2 | implementation. | |
3 | ||
4 | Erroneous code example: | |
5 | ||
6 | ```compile_fail,E0407 | |
7 | trait Foo { | |
8 | fn a(); | |
9 | } | |
10 | ||
11 | struct Bar; | |
12 | ||
13 | impl Foo for Bar { | |
14 | fn a() {} | |
15 | fn b() {} // error: method `b` is not a member of trait `Foo` | |
16 | } | |
17 | ``` | |
18 | ||
19 | Please verify you didn't misspell the method name and you used the correct | |
20 | trait. First example: | |
21 | ||
22 | ``` | |
23 | trait Foo { | |
24 | fn a(); | |
25 | fn b(); | |
26 | } | |
27 | ||
28 | struct Bar; | |
29 | ||
30 | impl Foo for Bar { | |
31 | fn a() {} | |
32 | fn b() {} // ok! | |
33 | } | |
34 | ``` | |
35 | ||
36 | Second example: | |
37 | ||
38 | ``` | |
39 | trait Foo { | |
40 | fn a(); | |
41 | } | |
42 | ||
43 | struct Bar; | |
44 | ||
45 | impl Foo for Bar { | |
46 | fn a() {} | |
47 | } | |
48 | ||
49 | impl Bar { | |
50 | fn b() {} | |
51 | } | |
52 | ``` |