-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Mention field punning in the docs for patterns #26108
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
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (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. 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. |
My only comment is that 'punning' is really jargony, and probably can't go without explanation. |
I considered not to mention it but it is the correct term for it so mentioning it is probsbly a good idea. Just calling it "short form" feels harder to remember as well. |
yeah, I am split on this, for the same reason as @brson. We've been trying to eliminate extra jargon as of late. Also, is 'punning' truly correct here? http://en.wikipedia.org/wiki/Type_punning seems more in line with how i've seen this used. I know we have a lint if you don't use this syntax, ie, Finally, if we do keep the jargon, it would be nice to put it in the Glossary and link to it. |
Both OCaml and Haskell calls it field punning though so I'd say it is correct. The warning only says that the field can be removed though. I can see why it should be removed though to reduce jargon since it does not help understanding the syntax in it is self. My main reason for adding the mention was more for the sake of it being a mnemonic since there did exist a term for it. On another note, maybe its worth changing the later examples to use the same form as
https://realworldocaml.org/v1/en/html/records.html |
yes, I have been meaning to do that. |
Maybe introducing the rebinding as sugar on top of the shorter form would be better, something like this for example Marwes@120ec30. |
@Marwes yes, that's great. Would you mind updating this PR with that commit? |
Looks like I created an additional commit as well here due to merging. The high-five bot discouraged rebasing when adding commits so I guess I should leave it as is, or should I squash them? |
@Marwes squashing them is just fine. Thanks again! r=me after |
Explains short form pattern syntax and then introduces the longer pattern matching as a rebinding of the fields instead. rust-lang#25779
@steveklabnik Done. |
@bors: r+ rollup |
📌 Commit 219ddd1 has been approved by |
Thanks so much! |
Adds a mention for the short form pattern syntax. Now without creating a PR to my own fork! #25779
Adds a mention for the short form pattern syntax. Now without creating a PR to my own fork!
#25779