Skip to content
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

Unable to chain-access tuple types #23694

Closed
ustulation opened this issue Mar 25, 2015 · 2 comments
Closed

Unable to chain-access tuple types #23694

ustulation opened this issue Mar 25, 2015 · 2 comments

Comments

@ustulation
Copy link

{Copying from here: http://stackoverflow.com/questions/29250677/unable-to-chain-access-tuple-types}
Given:

struct NameType([u8;64]);
name: (NameType, NameType);

i can do:

let def = &name.0   OR   &name.1

but i cannot do:

let def = &name.0.0   OR   &name.1.0

to access the internals. I have to do it twice:

let abc = &name.0;
let def = &abc.0;

why am i unable to chain it to access inner sub-tuples, tuple-structs etc?

rustc 1.0.0-nightly (ecf8c64e1 2015-03-21) (built 2015-03-22)
@rprichard
Copy link
Contributor

&name.0.0 doesn't work because 0.0 is a floating-point literal. Either (&name.0).0 or &name.0 .0 works.

The compiler prints a help notice for &name.0.0:

test.rs:9:24: 9:24 help: try parenthesizing the first index; e.g., `(foo.0)`

Issue #20287 requested that &name.0.0 work, but it was closed. That issue has relevant links (e.g. the tuple indexing RFC and the weekly minutes where this issue was discussed).

@steveklabnik
Copy link
Member

Yes, this is currently not a bug, as @rprichard mentions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants