Hi! I'm very much a beginner at rust (~3 weeks) but wanted to challenge myself to make something fun, so I made
guess-that-lang, a CLI game to see how fast you can guess the language of a code block. All feedback (including ideas for the game :)) would be appreciated, but to be specific, I'd love to know if
- Any of my code could be simplified
- Any of the crates I used could be replaced with a smaller/faster/better one
- Any of my application structure could be refactored for readability or maintainability
- Any handling of Results/Options could be improved
Thanks so much!
The code generally seems well-organized to me, I don't think there's anything that needs to be refactored or optimized in particular. A couple very minor things:
- There's a typo in the prompt ("corresponsing")
GameResult is basically the same as
Game has both public and private fields. While this is technically allowed by the compiler, I generally consider it bad style. Either make the struct pure data with all
public fields, or an invariant-preserving complex "object" with all private fields, exposing only the necessary state (perhaps immutably) via accessors.
Apologies for not reviewing the original code, bit I'd like to add my thanks to @H2CO3 for pointing out ControlFlow, which I had read about before
but had forgotten. Very useful!
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.