It seems Rust always defines a new module for each
.rs files. And this makes some trouble with me because I prefer to make one source file for one entity(struct/enum or function) and organize them using directory.
If I make
foo/bar2.rs and put
Bar2 struct in it, Rust makes two modules.
foo1::bar2::Bar2 // I `bar2` module is better to disappear.
If I follow my preferred policy (one file for one entity), I’ll get too many small unnecessary modules, and need to import them, re-expert them to container modules. And usually, names of the small modules are duplicated with the entity name regardless of suitability. I want to define modules only where necessary.
If I want to organize my entities and modules properly, I have to put too many entities into one file. This makes the file too long and harder to navigate between entities.
How can I avoid
.rs files to define modules automatically? It would be better if I can make Rust to define modules only for directories. Actually I don’t know why logical module structure must be matched to physical directory/file structure, but if it has to, I think considering directories only would be far nicer…