-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stabilize feature(match_beginning_vert) #47947
Stabilize feature(match_beginning_vert) #47947
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@bors r+ |
📌 Commit a99b5db has been approved by |
@bors rollup |
…inning_vert, r=petrochenkov Stabilize feature(match_beginning_vert) With this feature stabilized, match expressions can optionally have a `|` at the beginning of each arm. Reference PR: rust-lang/reference#231 Closes rust-lang#44101
…inning_vert, r=petrochenkov Stabilize feature(match_beginning_vert) With this feature stabilized, match expressions can optionally have a `|` at the beginning of each arm. Reference PR: rust-lang/reference#231 Closes rust-lang#44101
…inning_vert, r=petrochenkov Stabilize feature(match_beginning_vert) With this feature stabilized, match expressions can optionally have a `|` at the beginning of each arm. Reference PR: rust-lang/reference#231 Closes rust-lang#44101
RFC had 37 downvotes compared to 19 upvotes. Not obviously a good thing to be added to the language. |
I am very much against this being added to the language. it will lead to more confusing code! |
Since rust 1.25.0 you can add '|' at the beginning of match arm. See rust-lang/rust#47947. These changes support new syntax
Since rust 1.25.0 you can add '|' at the beginning of match arm (rust-lang/rust#47947). These changes support this new syntax
Same here. But nobody cares despite
|
this will be the one feature I will hugely disagree with in rust! unless their is extremely (strong willed) segment of developers that do like this. every example, I have been able to look at Involving, I find more confusing than with out the leading vertical bar! Not only that, but I have to yet to find strong evidence of many people wanting this feature! yes, there could be an example, but to the best of my knowledge, (which to be honest Isnt a lot) most code with this syntax added leads to more confusing code! |
For the record, while I don't have any idea how many people support this syntax, I do. I think F# uses vertical bars for |
The problem is not with the leading bar itself, the problem is that Rust now has two syntaxes to express the same thing. F# supports only leading bars. If Rust deprecated syntax without leading bars, that would probably be OK. |
Yeah all the arguments behind this RFC make no sense to me. There were alternatives that worked already and looked just as good. "I got used to it in F# and now I want it in Rust" is a bit of a strange argument to me. Rust shouldn't be some Frankenstein's monster of parts of different languages. Ideas should be evaluated based on their merit, and the value this brings to the table is very questionable to me. As for all the people arguing for flexible syntax and allowing different styles... This is how languages like Perl happened. "There is more than one way to do it" isn't a good thing; it's confusing and fragments the language. To quote Tim Peters "There should be one-- and preferably only one --obvious way to do it." Maybe this particular change is alright, but I just think a lot of the arguments made in this RFC are very dangerous and might lead Rust down the path many other failed languages have taken. Let's learn from their mistakes rather than repeat them because I really want Rust to succeed. There should be very strong arguments before we bloat the language spec more with little changes that have very minimal benefit to users and just add more mental overhead for beginners. |
This comment has been minimized.
This comment has been minimized.
2404: GRAM: support new syntax of match arms r=matklad a=Undin Since rust 1.25.0 you can add `|` at the beginning of match arm (rust-lang/rust#47947) These changes support this new syntax
Since rust 1.25.0 you can add '|' at the beginning of match arm (rust-lang/rust#47947). These changes support this new syntax (cherry picked from commit 079a37a)
This looks pretty useless to me, because you can't match (for me) obvious patterns like this: let something = Some(1);
match something {
| None
| Some(x) => println!("something = {}", x)
}; Rust complains that the let something = Some(1);
match something {
| None => (),
| Some(x) => println!("something = {}", x)
}; Maybe I'm misunderstanding the feature, and there is a way to match such a pattern? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Not really against having something similar to Haskell's guard statements. |
@valeth no one ever seems to have answered your question, but your comment seems a bit confused about the scope of this stabilization. Rust has had the ability to match multiple patterns with a single arm since before 1.0. there's no way to do what you suggest in your post, because This change was strictly syntactical: it makes |
This seems like such a useless pattern to add if it provides no extra functionality. In the end, things like this lead to people wanting their own style thrown in to vastly complicate the language without providing any extra practical benefit. Such as:
Whereas the difference with this is that it at least provides some benefit, but we start spiraling out of control with adding in features like this. |
With this feature stabilized, match expressions can optionally have a
|
at the beginning of each arm.Reference PR: rust-lang/reference#231
Closes #44101