4 ms·
You can implement traits for both kinds of references, so a function might accept both.
by phaylon 9y ago
You can implement traits for both kinds of references, so a function might accept both.
- johncolanduoni 9y agoThe same thing can still happen with Deref coercions or type inference, so this is something the compiler already has to deal with.
- phaylon 9y agoI'm not sure what you mean. Can you give an example?
- johncolanduoni 9y agoIf struct A implements trait S and trait T, and there are two functions fn foo(x: &S); fn foo(y: &T); in scope, then the compiler needs you to disambiguate foo(&a) if a: A. This isn't a whole lot different than disambiguating the same expression if the functions are: fn foo(x: &A); fn foo(x: &mut A);