Skip to content

Update guessing game to rand 0.10#4680

Open
sengmonkham wants to merge 1 commit intorust-lang:mainfrom
sengmonkham:update-rand-0.10
Open

Update guessing game to rand 0.10#4680
sengmonkham wants to merge 1 commit intorust-lang:mainfrom
sengmonkham:update-rand-0.10

Conversation

@sengmonkham
Copy link

Fix: #4679

Fixes the ch02 guessing game chapter, which was using rand 0.8.5 with APIs that have since been renamed in rand 0.9 and rand 0.10.

What changed

rand API migration:

Old (rand 0.8.5) New (rand 0.10)
rand = "0.8.5" rand = "0.10"
use rand::Rng use rand::RngExt
rand::thread_rng().gen_range(1..=100) rand::rng().random_range(1..=100)

Files updated:

  • listings/ch02-guessing-game-tutorial/*/Cargo.toml — version bump (×8)
  • listings/ch02-guessing-game-tutorial/*/Cargo.lock — regenerated, pinning rand v0.10.0 (×8)
  • listings/ch02-guessing-game-tutorial/*/src/main.rs — API calls updated (×7)
  • src/ch02-00-guessing-game-tutorial.md — prose, version specifiers, and cargo build console output updated
  • src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md — updated rand::thread_rng/Rng references

Migrate all ch02 guessing game listings from rand 0.8.5 to rand 0.10.

API changes applied:
- rand::thread_rng() -> rand::rng()
- .gen_range(1..=100) -> .random_range(1..=100)
- use rand::Rng -> use rand::RngExt (random_range moved to RngExt in 0.10)
- rand = "0.8.5" -> rand = "0.10" in all Cargo.toml files

Files changed:
- 8x Cargo.toml (version bump)
- 8x Cargo.lock (regenerated, pinning rand v0.10.0)
- 7x src/main.rs (API calls updated)
- src/ch02-00-guessing-game-tutorial.md (prose + console output updated)
- src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md (prose updated)
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.

Bug: guessing game rand version

1 participant