File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -212,8 +212,8 @@ http://doc.rust-lang.org/reference.html#trait-objects
212212"## ,
213213
214214E0034 : r##"
215- The compiler doesn't know what method to call because more than one does
216- have the same prototype. Example:
215+ The compiler doesn't know what method to call because more than one method
216+ has the same prototype. Example:
217217
218218```
219219struct Test;
@@ -230,7 +230,7 @@ impl Trait1 for Test { fn foo() {} }
230230impl Trait2 for Test { fn foo() {} }
231231
232232fn main() {
233- Test::foo() // error, what foo() to call?
233+ Test::foo() // error, which foo() to call?
234234}
235235```
236236
@@ -250,6 +250,28 @@ fn main() {
250250 Test::foo() // and now that's good!
251251}
252252```
253+
254+ However, a better solution would be using fully explicit naming of type and
255+ trait:
256+
257+ ```
258+ struct Test;
259+
260+ trait Trait1 {
261+ fn foo();
262+ }
263+
264+ trait Trait2 {
265+ fn foo();
266+ }
267+
268+ impl Trait1 for Test { fn foo() {} }
269+ impl Trait2 for Test { fn foo() {} }
270+
271+ fn main() {
272+ <Test as Trait1>::foo()
273+ }
274+ ```
253275"## ,
254276
255277E0035 : r##"
You can’t perform that action at this time.
0 commit comments