Description
I made the mistake of trying to do if let Result(foo) = bar
instead of if let Ok(foo) = bar
, and got a confusing error like the following:
error[E0532]: expected tuple struct/variant, found enum `Result`
--> src/service/prime.rs:18:16
|
18 | if let Result(parsed_number) = request.parse::<u64>() {
| ^^^^^^ not a tuple struct/variant
It took me a while to figure out what was wrong here; the error index entry for this error code was not very helpful either. Part of the problem is that the error tells me what it isn't, but not how what it is relates to that. To a beginner, the relationship between an Enum and one of its variants won't be intuitively obvious.
Perhaps the compiler feedback could also be improved here by suggesting Ok
/Err
(for Result
) and Some
/None
(for Option
), as these are common cases where this might occur. A more generic approach would be to simply list expected/valid variants for the specified Enum.
(As an aside, the contributing guidelines claimed that there would be an issue template, but there doesn't seem to be. I'm not sure whether that is intentional or not.)