This comment raises a suggestion that seems workable to me, and that might make Rust’s module system easier to understand for people coming from other languages: allow
/foobar/foobar.rs to be treated as
/foobar/mod.rs. To avoid conflict, if
/foobar/mod.rs exists, it would have to take precendence as the mod file, but if that file isn’t found we could fall back to
/foobar/foobar.rs. This seems more similar to how many other languages work and I don’t see any way it would be incompatible or conflictual. Thoughts?
More broadly, Rust’s module system seems to be the cause of far more confusion than it deserves, given its limited inherent complexity, and figuring out ways it could behave more like how people expect seems like a good idea.