trait Trait<T = ()> {
fn foo() -> T;
}
struct S;
impl Trait for S {
fn foo() -> u32 { 0 }
}
produces:
error[E0053]: method `foo` has an incompatible type for trait
--> src/lib.rs:28:17
|
22 | fn foo() -> T;
| - type in trait
...
28 | fn foo() -> u32 { 0 }
| ^^^ expected `()`, found `u32`
|
= note: expected fn pointer `fn()`
found fn pointer `fn() -> u32`
The diagnostic doesn't point out why T is (), which comes from the default type parameter. It would be helpful to explain this, as it may not be immediately apparent.
produces:
The diagnostic doesn't point out why
Tis(), which comes from the default type parameter. It would be helpful to explain this, as it may not be immediately apparent.