Hacker News new | past | comments | ask | show | jobs | submit login

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.



I think in any instance where you need to unpack every variant, `match` will almost always be the least verbose option.


I 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: