4
我有3个文件:lib.rs,file2.rs和file3.rs。我lib.rs我有这个:无法声明模块“无法在此位置声明新模块”
mod file2;
use file2::Struct2;
它运作良好。然而,在文件3做同样的事情用一个错误编译:
mod file2;
use file2::Struct2;
=> error: cannot declare a new module at this location
如果我删除国防部file2
声明我得到这个:
error: unresolved import `Struct2`
这有什么错呢?
工作。是“lib.rs”的特殊之处,因为它允许在其中使用“mod”? – imatahi
不,它只是树的根。也被称为'板条根'。请参阅本书的“箱子和模块”一章进行阐述。 –
这就是我所说的“它是否特别?”作为树的根,意味着是的。 – imatahi