Closed
Description
This code is wrong, but the error message is confusing:
trait Parser<T> {
fn parse(text: &str) -> Option<T>;
}
impl<bool> Parser<bool> for bool {
fn parse(text: &str) -> Option<bool> {
Some(true)
}
}
fn main() {
println!("{}", bool::parse("ok").unwrap_or(false));
}
Because I used bool
accidentally as a type name when not using the right syntax ... this is pretty confusing:
error: mismatched types [--explain E0308]
--> <anon>:7:14
7 |> Some(true)
|> ^^^^ expected type parameter, found bool
note: expected type `bool`
note: found type `bool`
error: aborting due to previous error