-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Identity operation enforced by compiler? #56923
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
Comments
Parentheses work: fn type_code(switch: bool) -> u8 {
(if switch { 128 } else { 0 }) + base_type_code()
} I'm not sure how the parser determines when conditionals-as-expressions need parentheses; I agree that it's very counterintuitive for a leading |
Not yet good, but already much better ;-) |
Related: #54186 |
I‘m gonna close this as a duplicate of #54186 as that seems to be pretty much exactly the same thing, with a different operator. |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
(Playground)
Output:
Shouldn't the above code also compile without the "0_u8 + "?
Note that clippy even complains about this identity operation.
The text was updated successfully, but these errors were encountered: