Cargo modules: why that structure choice

⚓ Rust    📅 2025-10-22    👤 surdeus    👁️ 3      

surdeus

Hi,
There is one thing that really annoys me with the module convention.
When creating a module, you can either do

--- root
    --- module
         --- mod.rs
         --- other.rs

or

--- root
    --- module.rs
    --- module
        --- other.rs

but the later forces to have module.rs out of the folder. It's not that clean.

Question:
Why don't we have:

--- root
    --- module
         --- module.rs
         --- other.rs

with rustc looking for the same name as the folder plus the rs extension? That way, everything is kept in its own folder, no need to navigate one upper level. And we get the added benefit of not having the same mod.rs name in the editors.

Thanks!

3 posts - 3 participants

Read full topic

🏷️ Rust_feed