Why this fires¶
A method in impl Trait for Type does not match the trait after substituting Self, trait arguments, associated types, and method-generic parameters. Parameter names/types and qualifiers, return type, generic bounds, and effect rows are all part of the contract.
trait Convert<T> { fn convert(self, value: T) -> T }
struct Converter {}
impl Convert<int> for Converter {
fn convert(self, value: str) -> str { value }
// ^^^^^^^ error[TE304]: incompatible trait signature
}Fix it¶
Copy the declared trait signature and apply the impl header's arguments. Here both value and the return type must be int. An omitted annotation may be inferred from the trait contract, but an explicit annotation must agree with it.