What's the rationale for making files modules? Modules being namespaces, and namespaces being collections, it's not desirable to have a file being a (large) collection of code. The feature that gives mixed feelings to the author (Re-exporting Imports) is indeed a workaround to this; since each file would externally generate one extra namespacing level, one reexports data structures in order to remove that level. This…
Files aren't modules. Modules are defined in the source code the same way as any named "item" in the language, like structs and functions. The only difference is that content of `{}` following the definition of a module can be read from another file. You can have a module without a file: mod foo { fn function_in_foo() {} mod bar { // this is crate::foo::bar module! } } but if you omit {}: mod foo; Rust will look for…
Every file is a module, but not every module is a file.
If `mod foo;` is the only way to make sure a file's code gets compiled, then at some point every file gets its own module, right?