r/learnrust • u/OkBug7820 • 11d ago
New to rust, how's my progress so far?
Hello, as you might have read from the title, i am new to rust, and being new to rust also means looking for ways to further improve, and one way to do that is to receive feedback, which i am seeking from this subreddit. I've read parts of the rust book and created projects in rust to put my skills to the test. I am currently working on a simple file IO CLI tool (https://github.com/reehanthenew/Simple-file-IO-CLI-tool/tree/main) and im currently proud of my progress. If i could receive some feedback (i accept any forms of feedback) that would be most appreciated. If i could receive more beginner-friendly projects or more learning materials, that would be much more appreciated. If you would like to monitor my growth, feel free to here: https://github.com/reehanthenew?tab=repositories
3
u/fbochicchio 11d ago
The first two funcions, prompt and pathname, do exactly the same thing, albeit for different purpose. I would suggest to only use one, maybe renaming it in a more neutral way. Also, I would make a general purpose function that both prints the question and get the answer.
Also, when getting the choice about what to do , you make multiple conversions to integer of the same string and don't check if the user answer with something different from a number.
These are not rust issues, but general programming issues, btw.
More specific about Rust : are you aware that expects crashesthe program if the underlying function returns an error? Sure, you get a nice error message but then the program quits. Is this the behaviour you want? If not, learn about error handling in Rust.
HTH
1
u/_player620 9d ago
Not rust, but git related: don't commit binaries unless absolutely necessary. They tend to bloat git object index. Use .gitignore config file to exclude build artifacts: https://github.com/rust-lang/rust/blob/main/.gitignore Try to utilize separate build directories, so binaries don't mix with sources.