This error occurs when the compiler doesn't have enough information to unambiguously choose an implementation.
For example:
trait Generator { fn create() -> u32; } struct Impl; impl Generator for Impl { fn create() -> u32 { 1 } } struct AnotherImpl; impl Generator for AnotherImpl { fn create() -> u32 { 2 } } fn main() { let cont: u32 = Generator::create(); // error, impossible to choose one of Generator trait implementation // Should it be Impl or AnotherImpl, maybe something else? }
To resolve this error use the concrete type:
trait Generator { fn create() -> u32; } struct AnotherImpl; impl Generator for AnotherImpl { fn create() -> u32 { 2 } } fn main() { let gen1 = AnotherImpl::create(); // if there are multiple methods with same name (different traits) let gen2 = <AnotherImpl as Generator>::create(); }