A module groups related Rust code into a hierarchical unit and provides a namespace for its symbols. Modules can be nested or split across source files. section 2.9
Use modules to organize code and control visibility:
- Declare an inline module with `mod name { ... }`, or use `mod name;` to include a module from another source file. section 2.9
- Declarations are private by default. Use `pub` to expose items, and `pub(crate)` to make an item available within the crate but not outside it. section 2.9
- A public item inside a private module is not thereby exported outside the crate; the containing module's visibility also matters. section 2.9
mod private_mod {
// ... #1
}
pub mod public_mod {
// ... #2
}
The declarations contrast private and public modules; use module visibility to shape which names are exposed. section 2.9
Module hierarchies can be nested deeply. Rust conventions use snake case for module names, helping distinguish them from most other names in `use` statements. section 2.9


































