-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Comment on shadowing with patterns #28893
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@@ -23,6 +23,31 @@ match x { | |||
|
|||
This prints `one`. | |||
|
|||
There’s one pitfall with patterns: like anything that introduces a new binding, |
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.
I wonder if it's worth having a section on shadowing? It is interesting to point out that Rust typically allows shadowing, and patterns are just a special case.
It's ALSO interesting (perhaps) to point out that you cannot shadow a constant or enum variant name.
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.
We talk about it in the variable bindings section, but this is a question that people ask about with patterns specifically, so I felt it was worth re-calling it out.
@bors r+ rollup |
📌 Commit bbc2056 has been approved by |
Fixes #28687