【发布时间】:2019-06-04 23:15:06
【问题描述】:
“结构的字段0 是私有的”pub 结构属性错误
在板条箱中
pub struct A(String, String);
pub struct C {
pub b: Vec<A>,
}
在main()中
...iter().map(|my_tuple:&A| (my_tuple.0.parse::<f64>().unwrap()));
为什么当属性为 pub、结构为 pub、父结构为 pub 时出现“struct is private”错误?
【问题讨论】:
-
请查看如何创建minimal reproducible example,然后查看edit 您的问题以包含它。我们无法分辨代码中存在哪些 crate、类型、特征、字段等。尝试在Rust Playground 上重现您的错误,或者您可以在全新的 Cargo 项目中重现它。还有Rust-specific MCVE tips。
标签: syntax module rust tuples access-modifiers