-
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
Allow irrefutable patterns in if-let statements #2081
Comments
This might not be very important but the disallowing of irrefutable patterns is nearly saying: let x = if true { 5 } else { 0 } |
They could simply be allowed, and the |
How would you tell if bool depends on |
The issue is e.g.
https://doc.rust-lang.org/book/first-edition/conditional-compilation.html#cfg
That's the big question. You'd need to track this during constant evaluation. Which definitely isn't easy, but should be a topic addressed if the warning rules around |
Ah, that makes sense. Is there a way to tell automatically if a value's true value for the |
There isn't right now, but it's also not too hard to add such a feature. |
Shall I start writing up a pull request to this repo? |
Sure. But I'd limit the RFC to just the |
That makes sense. Should I then include that the |
You have a much bigger chance of getting a single targeted RFC through, than a collection of features |
Then why not two different ones? |
Nothing speaks against that! |
#2086 was merged. |
This might seem a bit strange but not allowing them has brought up some strange results for me.
The equivalent can be done with a plain match statement which is defiantly not as clean. In the docs it says to just use a plane
let
statement, but that is not always possible because of macros. If you accept a pattern in a macro then the ability to have the following -instead of
The text was updated successfully, but these errors were encountered: