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…
One important technical reason is that you need to be able to add attributes to modules, like these examples: // Only compile this code if the “foo” Cargo feature is enabled. #[cfg(feature = "foo")] pub mod foo; // Platform-specific stuff, as with std::os. pub mod os { #[cfg(windows)] pub mod windows; #[cfg(unix)] pub mod unix; } // You can even choose which file to load the module from. #[cfg_attr(windows, path = "w…
edit: corrected typo