Implement tuple and tuple struct indexing (RFC 53)#16866
Implement tuple and tuple struct indexing (RFC 53)#16866bors merged 1 commit intorust-lang:masterfrom
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 |
src/librustc/middle/trans/expr.rs
Outdated
There was a problem hiding this comment.
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.