Why this fires¶
The concrete type implements the requested trait name, but with different type
arguments. Trait witnesses are exact: implementing Sink<str> does not prove
Sink<int>.
trait Sink<T> { fn push(self, value: T) }
struct Log {}
impl Sink<str> for Log { fn push(self, value: str) {} }
fn write_int<S>(sink: S) where S: Sink<int> {}
write_int(Log {})
// ^ error[TE482]: found Sink<str>, required Sink<int>Fix it¶
Pass a type with the exact required witness, change the generic bound, or add a non-overlapping implementation for the required arguments when the semantics are valid.