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
Update if-let.md #38436
Update if-let.md #38436
Conversation
Calling if-let a combination of if and let is confusing, as some may be led to believe that it's a literal combination, instead of syntactic sugar added to the language as a convenience. What's there to stop someone from thinking if-let is just if and let together? I do think this article does a good job of implying what's really going on; however, I was only able to notice this after I had begun to understand if/while-let statements, courtesy of the Rust IRC chat. Basically, this article lacks the clarity and explicitness an inexperienced programmer like me needs in order to understand the contents fully. This is shown by my inability to understand the if-let concept from this page of the Book alone. I think convenience, sugar, and (if-let != if + let) should all be made mention of in a clear, explicit manner. I lack confidence in my understanding of this issue, so I wrote just enough to hopefully get my thoughts across.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (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. |
Thanks for the PR and feedback about this section! I can see how it might be misleading to compare
EDIT: typo |
src/doc/book/if-let.md
Outdated
`if let` allows you to combine `if` and `let` together to reduce the overhead | ||
of certain kinds of pattern matches. | ||
`if let` is a figurative combination of `if` and `let`. `if let` does not literally | ||
mean `if` + `let` to the compiler; it has its own special meaning,which was added for |
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.
needs a space after ,
r? @frewsxcv |
I added what you suggested @frewsxcv, plus an extra sentence about overhead and convenience because I thought it might help the reader understand the rest of the page better, I'm unsure, however; maybe it adds more complexity than necessary. What do you think? |
Your changes look good to me, thanks! @bors r+ rollup |
📌 Commit ebf07da has been approved by |
src/doc/book/if-let.md
Outdated
`if let` allows you to combine `if` and `let` together to reduce the overhead | ||
of certain kinds of pattern matches. | ||
`if let` allows us to match [patterns][patterns] within the condition of an [if][if]. | ||
As a consequence, we reduce the overhead of certain kinds of [pattern][patterns] matches |
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.
After thinking about it more, I'm not a huge fan of the word "consequence" here since it usually describes the results of an action, and there's not really an action here. What about:
if let
allows us to reduce...
or
This feature allows to reduce...
or
This allows us to reduce...
or something else. What do you think?
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.
What about this? I'd rather avoid using allow twice like that.
if let
permits pattern matching within the condition of an if statement.
This allows us to reduce the overhead of certain kinds of [pattern][patterns] matches
and express them in a more convenient way.
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.
Sounds great :)
@bors r- |
ping @bluecereal, want to make the update @frewsxcv mentioned? |
Looks great, thanks for being patient with this! 🎉 @bors r+ rollup |
📌 Commit fb7f211 has been approved by |
Update if-let.md Calling if-let a combination of if and let is confusing, as some may be led to believe that it's a literal combination, instead of syntactic sugar added to the language as a convenience. What's there to stop someone from thinking if-let is just if and let together? I do think this article does a good job of implying what's really going on; however, I was only able to notice this after I had begun to understand if/while-let statements, courtesy of the Rust IRC chat. Basically, this article lacks the clarity and explicitness an inexperienced programmer like me needs in order to understand the contents fully. This is shown by my inability to understand the if-let concept from this page of the Book alone. I think convenience, sugar, and (if-let != if + let) should all be made mention of in a clear, explicit manner. I lack confidence in my understanding of this issue, so I wrote just enough to hopefully get my thoughts across.
☀️ Test successful - status-appveyor, status-travis |
Calling if-let a combination of if and let is confusing, as some may be led to believe that it's a literal combination, instead of syntactic sugar added to the language as a convenience. What's there to stop someone from thinking if-let is just if and let together?
I do think this article does a good job of implying what's really going on; however, I was only able to notice this after I had begun to understand if/while-let statements, courtesy of the Rust IRC chat.
Basically, this article lacks the clarity and explicitness an inexperienced programmer like me needs in order to understand the contents fully. This is shown by my inability to understand the if-let concept from this page of the Book alone.
I think convenience, sugar, and (if-let != if + let) should all be made mention of in a clear, explicit manner. I lack confidence in my understanding of this issue, so I wrote just enough to hopefully get my thoughts across.