无法链访问元组类型

Unable to chain-access tuple types

鉴于:

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

我能做到:

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

但我做不到:

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

访问内部。我必须做两次:

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

为什么我无法链接它来访问内部子元组、元组结构等?

rustc 1.0.0-nightly (ecf8c64e1 2015-03-21) (built 2015-03-22)

如评论中所述,foo.0.0 将被解析为具有数字。这是 originally mentioned in the RFC, specifically this:

I'd rather not change the lexer to permit a.0.1. I'd rather just have that be an error and have people write out the names. We could always add it later.

您当然可以提交错误,但作为解决方法,请使用括号:

(foo.0).0

在我看来,您无论如何都不应该嵌套那么深的元组。我强烈建议在您慢慢发疯决定是否要 foo.0.1.2foo.1.2.0.

之前为字段命名

除了上述答案外,我还发现间隙会产生奇迹 :) 所以;

foo.0. 0  OR  foo.0 . 0 etc all work

很好。不知道这意味着什么,但如果有人愿意的话,有一种方法可以将它链接起来(不求助于括号)