5
我想弄清楚如何在Rust中编译多文件板条箱,但我不断收到编译错误。如何在Rust中编译多文件箱?
我有一个文件我想导入到箱子thing.rs:
mod asdf {
pub enum stuff {
One,
Two,
Three
}
}
我的箱子文件test.rc:
mod thing;
use thing::asdf::*;
fn main(){
}
当我运行锈生成test.rc我得到:
test.rc:3:0: 3:19 error: `use` and `extern mod` declarations must precede items
test.rc:3 use thing::asdf::*;
^~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
显然有一些简单的关于如何模块,板条箱和使用工作,我只是没有得到。我的理解是那个mod有些东西;对于同一目录中的文件或extern mod某些内容;库路径上的库导致目标文件被链接。然后使用将允许您导入模块的一部分到当前文件,功能或模块。这似乎适用于核心库中的东西。
这是0.6版本的锈编译器。