Files:
- example.rs (root of our modules tree, generally named lib.rs or main.rs when using Cargo)
- first.rs
- second/
- mod.rs
- sub.rs
Modules:
- example -> example
- first -> example::first
- second -> example::second
- sub -> example::second::sub
- third -> example::third
example.rs
pub mod first;
pub mod second;
pub mod third {
...
}
The module second have to be declared in the example.rs file as its parent is example and not, for example, first and thus cannot be declared in the first.rs or another file in the same directory level
second/mod.rs
pub mod sub;