Imagine the following directory structure:
code /
`- main.rs
- something /
`- mod.rs
If in main.rs you are doing mod something; then it will look in the something/mod.rs for use as the contents of the module declaration for something .
An alternative to this is the presence of the something.rs file in the code/ directory.
So, to write when you write an empty module declaration, for example mod something; , it looks either in:
- file named
something.rs in the same directory - a file called
mod.rs in a folder named something in the same directory
It then uses the contents of any of these files to be used as the contents of the module declaration.
source share