this post was submitted on 24 Dec 2024
33 points (100.0% liked)
Rust
6244 readers
16 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
@kionite231
You could save the inputs done by the user and ask if the guesses should be listed after you did enter the correct number.
done :D
@kionite231
You could also color the inputs in different colors
Maybe red if it was wrong and green if the guess was right.
You could also keep that color coding if the list of inputs is getting shown at the end.
but to do that I have to use external deps? which I am not comfortable doing. (I am newbie :) )
Coloured text does not require a dep. It is just about printing the right colour codes like:
The libraries just make it easier so you don't need to remember or know what those codes mean.
I thought, colour codes are platform dependent, will it work on windows
I usually run things on Linux or macOS, but using a library (crate) may add portability, imo
🤔 I think the vt100 protocols (where the escape code come from) predate windows and I think all modern terminals still use those as the base. So I think they are cross platform. From a quick search it looks like they are the same codes on windows. So I dont think the libraries are doing anything special for cross platform support.
I see, so I was wrong then
Maybe I should try colour codes on windows when I get to it 😅 thanks for the info
Nice work and congrats on your progress! Being new and uncomfortable with dependencies, this project might be a good opportunity to read and apply chapter 7 of the rust book if you haven't already. Specifically 7.2 defining modules ... and the sections that follow.
As your projects increase complexity it's really useful to shift chunks around (within main.rs and into other files/directories). Doing it now will make it easier to see the individual parts (vs waiting till a project has a lot going on). It might make dependencies feel less unfamiliar.
@kionite231
Okay I do understand that maybe I will get another idea if so I will let you know.