Skip to content

Update rand example to fix breaking changes in v0.10.1#4748

Closed
grimmfieber wants to merge 1 commit intorust-lang:mainfrom
grimmfieber:fix-rand-api-v0.10
Closed

Update rand example to fix breaking changes in v0.10.1#4748
grimmfieber wants to merge 1 commit intorust-lang:mainfrom
grimmfieber:fix-rand-api-v0.10

Conversation

@grimmfieber
Copy link
Copy Markdown

Since new users tend to use the latest version of crates instead of the specific versions mentioned in the text, I have updated the rand crate to the latest version (v10.1) to ensure a seamless learning experience.

The rand::thread_rng() function has been updated to the new rand::rng() API introduced in recent versions.

Changes:

  • Cargo.toml: Upgraded rand dependency to 0.10.1.
  • listings/ch02-guessing-game-tutorial: Updated listing-02-03/src/main.rs to replace rand::thread_rng() with rand::rng().

Impact:
This change prevents "method not found" errors for beginners who unknowingly install the latest version of the rand crate while following the Guessing Game tutorial.

@grimmfieber grimmfieber closed this May 4, 2026
@grimmfieber grimmfieber deleted the fix-rand-api-v0.10 branch May 4, 2026 23:28
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