-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Improvements to range match patterns #880
Conversation
|
||
Just as the match pattern `i...j` matches numbers between `i` and `j`, `i...` | ||
will match all numbers greater than `i`, and `...j` will match all numbers | ||
greater than `j`. This capability is extended to `char` as well, under the same |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be:
...j
will match all numbers less than j
?
Thanks @mdinger, fixed. |
Since |
@oli-obk To be honest, I found it a bit difficult to figure out the front-runner in that thread, since there are a lot of different suggestions there, and so I basically decided to ignore it until there's some specific proposal that comes out of that discussion. If exclusive ranges were allowed in patterns, I would say that |
Hmm. This seems like a nice thing to have, but I think it's probably going to have to come after 1.0, which implies that the exhaustiveness checking will have to be weaker, which is probably ok. |
We discussed this at the triage meeting today. We all thought it was probably a nice addition to the language, however, it is too low priority to consider before 1.0. Therefore I will close this as postponed. Tracking issue is #947. |
Bump. I except this and semiopen (It's not a priority although). |
Is there any possibility of this getting split into two RFCs? I'm specifically interested in the exhaustive pattern matching. |
We can currently use patterns of the form
2...5
in matches, but not2...
or...5
(which one would expect by analogy withRangeTo
/RangeFrom
). This RFC adds those new forms; I will update it if the existing pattern range syntax is going to change.Additionally, this RFC proposes performing exhaustiveness checks on patterns for integer types and
char
.Note: Since there are a lot of RFC PRs recently, including several that I've proposed, I want to note that this one in particular poses a (rather minor) backwards compatibility issue. Some rare match patterns that compile now would be rejected.
Rendered.