Can I avoid eager ambiguity resolution for trait implementations with generics?

Can I avoid eager ambiguity resolution for trait implementations with generics?

No.

Is it possible to have [ambiguity resolution to be done at the call site, rather than at the definition site]?

No.


There’s a (long-delayed) RFC for specialization that will allow overlapping trait implementations, but only when one of them is more specific than the others. I don’t believe this is true for your case, so it would not help.

See also:

  • Conflicting implementations of trait in Rust
  • Why do I get “conflicting implementations of trait” for f32 which does not implement Ord?
  • Why do I get a conflicting implementations error when specializing a trait?
  • How is there a conflicting implementation of `From` when using a generic type?

Leave a Comment