Mastodon Feed: Post

Mastodon Feed

jsonstein@masto.deoan.org ("Jeff Sonstein") wrote:

I am not so sure that this is syntactic sugar which I wish to consume:

#LearningRust

"Using if let means less typing, less indentation, and less boilerplate code. However, you lose the exhaustive checking that match enforces. Choosing between match and if let depends on what you’re doing in your particular situation and whether gaining conciseness is an appropriate trade-off for losing exhaustive checking.

In other words, you can think of if let as syntax sugar for a match that runs code when the value matches one pattern and then ignores all other values."