Hello everyone,
I’m building a CLI application. This is my second program in Rust, so I don’t have much experience yet or a strong understanding of best practices.
I’m sharing my code in case anyone would like to give feedback or suggestions to help me improve.
I’ve also used AI to help me understand some parts that I still find difficult, but my main goal is to gain a solid understanding of the language and how it works.
Here is the GitHub repository:
https://github.com/AppBlitz/github-user-activity
If you find any issues or have suggestions, I would really appreciate your feedback.
Thank you very much for your time and help.
Do you mind to share the github link, instead of the git repository? A disk space is expensive recent time.
@sww1235 @MOCKBA I've now fixed the link; I'm sorry for my mistake
I think you are splitting your source code into too many small files - at least for my taste.
Also - I notice you have both src/lib.rs and src/main.rs.
Normally you don't have both - it is either a lib or a bin.
If it is a lib you can put main(s) in src/bin or examples/
Then you run them with with cargo run --bin main or cargo run --example main.
Maybe I am missing something. As I read Refactoring to Improve Modularity and Error Handling - The Rust Programming Language it recommends splitting a program into a main.rs, a lib.rs, and then other modules. Did I misread it?
No, I agree with you. I frequently do lib.rs + main.rs for executable projects. I just make sure to declare all mods within lib.rs, not main.rs, even though it’s technically permissible to do a mix of both.