keyword
Rust mod: organize code into modules
A module groups related items and creates a namespace. An inline module contains its items between braces; file-based modules have separate layout rules. Expected output (not executed): 0 Why: The qualified path selects a public function in the module. Common mistake: A module is not automatically a separate crate.
Formal Syntax & Structure
rust syntaxrust
mod name { /* items */ }Working Example
Example Snippetrust
mod temperature { pub fn freezing_celsius() -> i32 { 0 }}
fn main() { println!("{}", temperature::freezing_celsius());}