Say I have this code:
pub trait A {}
pub trait B {}
pub trait SomeBehavior {
fn func() -> bool;
}
And I want to provide the blanket implementation for A
and B
like this:
impl <T> SomeBehavior for T where T: A {
fn func() -> bool { true }
}
impl <T> SomeBehavior for T where T: B {
fn func() -> bool { false }
}
But this gives following error:
error[E0119]: conflicting implementations of trait `SomeBehavior`
--> src/lib.rs:12:1
|
8 | impl <T> SomeBehavior for T where T: A {
| -------------------------------------- first implementation here
...
12 | impl <T> SomeBehavior for T where T: B {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
Why the compiler treats two different implementations on different traits as same implementation?