Rust doesn't seem to distinguish between different implementations of a trait only if they differ by an associated type.
How can I implement a method on all kinds of collections/iterators, but have specific implementations for each concrete type they contain?
error: conflicting implementations for trait
Foo
[E0119]
trait Foo { fn foo(self); }
impl<T> Foo for T
where T: IntoIterator<Item=u32>
{
fn foo(self) {
self.into_iter();
}
}
impl<T> Foo for T
where T: IntoIterator<Item=u16>
{
fn foo(self) {
self.into_iter();
}
}
fn main() {
vec![0u32].foo();
vec![0u16].foo();
}