This is an example of my code. The error says there are conflicting implementations of trait Foo<std::vec::Vec<u8>>
but I don't see why this happens because the third impl should only be happening where S: Foo and I didn't impl Foo.
use std::io::Read;
fn main() {
}
trait Foo<T> {
fn example() -> String;
}
impl<S> Foo<Vec<u8>> for S where S: Read {
fn example() -> String {
String::from("Vec<u8>")
}
}
impl<S> Foo<u32> for S where S: Read {
fn example() -> String {
String::from("u32")
}
}
impl<S,T> Foo<Vec<T>> for S where S: Foo<T> {
fn example() -> String {
String::from("anything")
}
}
It works if in the last impl I switch from S to an actual type.
For example: Rust Playground