Skip to content

Conversation

@mohitnandaniya-devloper

This pull request finalizes the code for the Chapter 2 guessing game tutorial, implementing the completed logic across the sequential steps (02-02 through 02-06).

Changes Included:

  1. Code Implementation: The src/main.rs file in the listing directory was updated with the full, final guessing game logic, combining the steps for input, random number generation (secret_number), looping, and comparison using match.
  2. Dependency Update: The rand crate version was updated to 0.9.2 in the project manifest (listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.toml).
  3. CI Test Fix: The rand = "0.9.2" dependency was added to packages/trpl/Cargo.toml to ensure the book's embedded Rust documentation tests (doctests) can successfully compile and run, resolving the previous unresolved import rand error.

Why

The purpose of this contribution is three-fold: to ensure the educational content is complete, to maintain dependency hygiene, and to fix a critical test failure in the continuous integration (CI) pipeline.

  1. Educational Logic Completion: This PR provides the accurate, final source code corresponding to the end of the "Programming a Guessing Game" chapter, ensuring the example is fully functional for all readers.
  2. Project Health & Dependency Maintenance: It updates a core non-standard library dependency (rand) to a newer version, which is a key part of routine maintenance.
  3. Resolves CI/Test Failure: The dependency change in packages/trpl/Cargo.toml resolves a compilation error in the book's test harness, ensuring the overall repository test suite remains healthy and passes.

Verification

All code has been locally compiled, formatted (rustfmt, dprint), and verified to run correctly.

@mohitnandaniya-devloper mohitnandaniya-devloper force-pushed the fix/ch02-guessing-game-rand-0.9.2 branch from e75c432 to 993b662 Compare November 25, 2025 19:34
@mohitnandaniya-devloper
Copy link
Author

Hi team! I'm following up on this PR. I previously submitted a request that was deleted along with its branch. This new PR incorporates the feedback from the previous request (specifically the query about [ @olino03 - The markdown files are not updated correctly. There's a section named 'Updating a Crate to Get a New Version' where it builds up knowledge related to how crate versions are handled which also would need updating.]). Let me know if any further changes are needed! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant