Closed briansmith closed 7 years ago
Hmm, I tend to agree. The original PR used a match
and then another PR simplified this particular example (and probably correctly so) to an if let
. Perhaps it may be worthwhile to finding an example out in the wild unless someone else has another example in mind?
I use if let
much more often than match
.
I don't we can say match
or if let
is more general or more common, but as a matter of style I think that example should use match
- where you have where there is both an if let
and an else
branch, it is nearly always better to use match
.
Maybe it's good to have two examples, one with if let
and one with match
. Then we can direct people to the specific example that most closely matches their code.
The example seems unrealistic because it uses
if let
instead ofmatch
. The example should usematch
since it is more general. Most of the cases where I would use this pattern would require the use ofmatch
.