-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Don't require parentheses when accessing nested tuple #20287
Comments
The RFC originally allowed indexing nested tuples without parentheses, but the team decided that they didn’t want to contort the grammar to support that. FWIW, I recently discovered that parentheses aren’t actually required: you can use whitespace instead; e.g., |
Okay, feel free to close this if the team thinks it's not worth implementing. |
Not high-priority, but it would still be nice to fix this syntax and avoid the search on how to work around it. |
If you have a nested tuple like this:
let a = ((1u8, 2u8), (3u8, 4u8));
You can't access it like this:
println!("{}", a.1.1);
Instead, you have to do this:
println!("{}", (a.1).1);
I can't think of any good reason why the former shouldn't be allowed. Maybe rustc is parsing it as the number
1.1
? It seems like it shouldn't be hard to fix, since the compiler is already able to suggest adding the parentheses.The text was updated successfully, but these errors were encountered: