I have a directory like this:
.
├── a.rs
├── b.rs
└── main.rs
main.rs:
mod a;
use a::a;
fn main() {
println!("Hello, world!");
a();
}
a.rs:
mod b;
use b::b;
pub fn a() {
b();
}
b.rs:
pub fn b() {
println!("b");
}
rustc complaints in a.rs about
file not found for module `b`
help: to create the module `b`, create file "src/a/b.rs" or "src/a/b/mod.rs"rustc(E0583)
If I put mod b; in main.rs, and replace mod b; with use crate::b::b; in a.rs, everything works well.
My question is: do I have to put every mod xxx; in the file where main() locates? I just want to call functions in the same-level rs files