2

Is it possible to implement two traits with conflicting method names in Rust? I know that it gives you a multiple applicable methods in scope error, but is there a way to resolve this? For example, some languages handle multiple inheritance by allowing you to explicitly specify which one method should take precedence

Casebash
  • 114,675
  • 90
  • 247
  • 350

1 Answers1

8

You want universal function call syntax. The following are all equivalent:

let v = 32;
let _ = v.clone();
let _ = Clone::clone(&v);
let _ = <i32 as Clone>::clone(&v);
DK.
  • 55,277
  • 5
  • 189
  • 162
  • https://doc.rust-lang.org/1.30.0/book/2018-edition/ch19-03-advanced-traits.html#fully-qualified-syntax-for-disambiguation-calling-methods-with-the-same-name – Mathieu CAROFF Jan 06 '22 at 08:31