this post was submitted on 04 Jul 2023
11 points (100.0% liked)

Programming

13376 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS
 

I just discovered this one right after discovering the if-let, this is amazing to be able to do positive and negative pattern matching without using a full blown match statement!

People are complaining that Rust is adding too many features to the language but I have to admit those recent additions are very good... What do you think?

top 4 comments
sorted by: hot top controversial new old
[–] shakesbeare 7 points 1 year ago (1 children)

Let else use consistently one of my favorite patterns because it enables really slick guard clauses and minimizes indentation. It’s just one more thing that enables the Enum-centric approach to programming that I love so much about rust and feels much nicer than alternatives.

10/10 from me

[–] thingsiplay 2 points 1 year ago* (last edited 1 year ago)

10 divided by 10 is 1. So 1 upvote from you? (just joking) This is a great feature and makes so much sense in the Rust language, with (as you say) Enum-centric programming style.

[–] TehPers 3 points 1 year ago

I'd like to know which people are complaining about Rust adding too many features. In my experience, it's been really slow to add features compared to, for example, C#. I think they've been very careful about adding good features that solve real problems, like let-else being used to take a common programming problem (guards) and create a single idiomatic solution as opposed to the previous highly verbose solutions. Most of their changes tend to just be cleanup and fixing inconsistencies in the language, in my opinion, or at best small but impactful additions.

[–] thingsiplay 2 points 1 year ago

I think this helps simplifying code when it is needed. I agree that the "negative pattern match" is useful and I will use it probably. Didn't keep up with Rust in the last 6 months and didn't know about this feature at all!