3 ms·
Yes, though that doesn't put the value of the `Ok` variant into any scope. At the end of the day, if you need maximum flexibility for whatever you're doing then
by kibwen 4y ago
Yes, though that doesn't put the value of the `Ok` variant into any scope. At the end of the day, if you need maximum flexibility for whatever you're doing then you still need to reach for `match`, even if it's a bit more verbose.
- dllthomas 4y agoI mean, in all cases `if let` is for when there's nothing in other constructors that you want to talk about. That'll be every time you match on `Option<T>`, `Result<T, ()>`, or `Result<(), T>`, all of which come up at least occasionally, and will occasionally be other cases. Edited to add: I don't mean to imply that you should always use `if let` for those cases - that may be but I reserve judgement on it.
- jamincan 4y agoI think in any instance where you need to unpack every variant, `match` will almost always be the least verbose option.