Super short example. This generates a conflicting requirement error, but I want Rust to be able to tell between the types that implement all of the trait requirements. Is it possible?
trait A {
fn foo();
}
trait B {}
trait CM {}
trait DM {}
impl<T> A for T
where T : CM + B
{
fn foo() {
}
}
impl<T> A for T
where T : DM + B
{
fn foo() {
}
}
fn main() {}
trait A {
fn foo();
}
trait CM {}
trait DM {}
impl<T> A for T
where T : CM
{
fn foo() {}
}
impl<T> A for T
where T : DM
{
fn foo() {}
}
fn main() {}
This generates a conflicting requirement too, so I guess what I want to do is impossible? I want to provide implementation only for part of the types, namely those types that implement a certain trait (or even better, all of the specified traits).
In the second post there might be some type that implemented both traits, which would lead to ambiguity. I guess the same reasoning applies to my first post. Well, then how do I achieve what I want? I need to specialize the implementation.