-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Implement tuple and tuple struct indexing (RFC 53) #16866
Conversation
Awesome, you're an implementastic whirlwind! I'm not a reviewer, but I guess some one will ask how this change deals with nested tuples and the syntax |
@@ -702,6 +705,38 @@ fn trans_rec_field<'a>(bcx: &'a Block<'a>, | |||
}) | |||
} | |||
|
|||
fn trans_rec_tup_field<'a>(bcx: &'a Block<'a>, |
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.
Does this differ to trans_rec_field
in any significant way; I wonder if it would be possible to deduplicate the shared code.
I would like to see many more tests, e.g.:
|
a8b3bf2
to
f5a0863
Compare
I’ve added the tests you suggested, and they all pass. I’ve also removed the code duplication in |
f725e6c
to
1fb5609
Compare
This allows code to access the fields of tuples and tuple structs: let x = (1i, 2i); assert_eq!(x.1, 2); struct Point(int, int); let origin = Point(0, 0); assert_eq!(origin.0, 0); assert_eq!(origin.1, 0);
1fb5609
to
bf274bc
Compare
Rebased. r? |
This allows code to access the fields of tuples and tuple structs behind the feature gate `tuple_indexing`: ```rust #![feature(tuple_indexing)] let x = (1i, 2i); assert_eq!(x.1, 2); struct Point(int, int); let origin = Point(0, 0); assert_eq!(origin.0, 0); assert_eq!(origin.1, 0); ``` Implements [RFC 53](https://github.com/rust-lang/rfcs/blob/master/active/0053-tuple-accessors.md). Closes #16950.
This allows code to access the fields of tuples and tuple structs behind the feature gate
tuple_indexing
:Implements RFC 53. Closes #16950.