Modules and the Filesystem

Updated

October 31, 2026

Modules and the Filesystem

Rust’s module system organizes code into distinct namespaces and controls privacy.

The Modern Module Mapping

In modern Rust (2018/2021/2024 editions), declaring mod network; in src/main.rs resolves to src/network.rs or src/network/mod.rs.

// In src/network.rs
pub fn connect() {
    println!("Connecting to network host...");
}