Closed MitchellBerend closed 1 year ago
I love less noise in the root directory 🙂 The current module structure is ad-hoc and evolved as the project grows. And I'm still navigating the best structure.
I mostly added those files due to unfamiliarity with the module system. But I'd happy to remove the model/mod.rs
and similar modules if the code still works 🧹
I imagine it should be better for incremental compilation to import only relevant modules and not just reexporting ones (but I don't have enough Rust knowledge to confirm this).
Ideally, I'd love to keep only lib.rs
and main.rs
on the top level and move everything inside directories. And I still would like to have a separate directory with a module for executing each command, something like:
run/
* sync.rs
* install.rs
* default-config.rs
* completion.rs
Where lib.rs
just calls run::sync(sync_args)
or run::completion(completion_args)
Also, some info I found on Rust module structure and best practices:
run/
* sync.rs
* install.rs
* default-config.rs
* completion.rs
I very much like this structure as well. I personally only make exceptions once there is a single file. The exception in this case would be the src/install.rs
file.
Rust provides a couple of ways to organize projects. Currently there is a file in the root that imports all files in a dir with the same name. I propose we add a
mod.rs
file to the dir in question so it can be imported insrc/lib
directly. It would mean the same number of files but less noise in the root. Themod.rs
is the equivalent of the python__init__.py
.With change![image](https://user-images.githubusercontent.com/45570310/197145787-ea60e964-2cb0-4f40-bdc6-67beb89e817c.png)
Without change![image](https://user-images.githubusercontent.com/45570310/197145909-44d43f2b-89f5-47cc-915e-da3f2e463bf2.png)