我试图从一个文件中与多个其他的文件使用的功能。
当我尝试添加“国防部somefile”的文件,锈编译希望他们可以嵌套在一个子文件夹,这是我不希望如何构建项目,因为这将意味着每次复制文件。
// src/main.rs
mod aaa;
mod bbb;
fn main() {
aaa::do_something();
bbb::do_something_else();
}
// src/aaa.rs
mod zzz; // rust compiler wants the file to be nested in a subfolder as aaa/zzz.rs
pub fn do_something() {
zzz::do_stuff();
}
// src/bbb.rs
mod zzz; // again, compiler wants the file nested in a subfolder as bbb/zzz.rs
pub fn do_something_else() {
zzz::do_stuff();
}
// src/zzz.rs
pub fn do_stuff() {
// does stuff here
}
我想是不是有重复它在每个文件的子文件夹能够离开src/zzz.rs
根src
文件夹和使用中的任何项目中的其他文件,它的功能,(例如:src/aaa/zzz.rs
,src/bbb/zzz.rs
)。