3 ms·
> And I suspect that now that "if let ... else" is available that that will become the preferred style for handling two cases. if let Pattern(binding) = th
by pitaj 4y ago
> And I suspect that now that "if let ... else" is available that that will become the preferred style for handling two cases.
if let Pattern(binding) = thing { ... } else { ... }
has been available for a long time. What was recently stabilized is
let Pattern(binding) = thing else { ... };
which is syntax sugar for
let binding = if let Pattern(binding) { binding } else { ... };
And facilitates easier unwrapping in early exit or default scenarios, without an extra level of indentation.
- khuey 4y agoYes, you're right of course. That's what I get for commenting while not fully awake :)