-
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
RFC: let-expression #3159
Closed
Closed
RFC: let-expression #3159
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3405606
init let expression rfc
HKalbasi c2bdecd
change first paragraph of #why now?
HKalbasi c86f4c2
Update 0000-let-expression.md
HKalbasi 30e09b4
Prepare to remove not operator
HKalbasi 9e77c59
Add future of matches section
HKalbasi d6c3ac1
update hard to read let expression section
HKalbasi 8561362
fix a typo
HKalbasi 8c2609f
Add Let expression type section in drawbacks
HKalbasi 39ab42d
Add a practical example
HKalbasi 1903255
Add another practical example
HKalbasi 1b0a4bf
Add another practical example
HKalbasi 6310916
Try to make examples more readable
HKalbasi 9b38567
Move compare with let-else to let-else section
HKalbasi 8d72621
Remove parenthesis from let expressions
HKalbasi f52c822
Move operator not to future possibilities
HKalbasi 0a8b92c
Update practical examples
HKalbasi e2e24b9
Fix English grammar error
HKalbasi 7746b6e
Update section Why now
HKalbasi 6e91ca7
Fix a problem in examples
HKalbasi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is more like a practical example of the existing
if_let_chains
feature (if you must include acontinue
for the number of indentations)this is also more consistent with the way people would write
rather than
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.
if-let-chain still need one indentation, because variables are bound inside of if body (like if-let) but in the example with
||
variables are bound after statement (like let-else). If you believe if-let can't meet the needs that let-else provide, The same statement is true for if-let-chain and this RFC.I am agree and prefer explicit
if
over||
in normal cases. Without bindings, both behavior is the same (both in current rust and in this RFC) but because binding rules for them are different (for good reasons; for example accessing if-let variables after body is surprising) you can save one indentation by||
one.And it is worth noting that
!next_condition || continue;
is completely valid and working in today rust. But!next_condition else { continue };
isn't and won't, so let-else syntax has a negative point here and this RFC is more consistent with rust.