Imagine the following directory structure:
code/
`- main.rs
- something/
`- mod.rs
If in main.rs you do mod something;, then it’ll look in the something/mod.rs file to use as the contents of the module declaration for something.
The alternative to this is to have a something.rs file in the code/ directory.
So to recap, when you write an empty module declaration such as mod something;, it looks either in:
- a file called
something.rsin the same directory - a file called
mod.rsin a folder calledsomethingin the same directory
It then uses the contents of either of those files to use as the contents of the module declaration.