From 1b7ab2a95fffa46a4a1eb6b76843f01f03ca51b4 Mon Sep 17 00:00:00 2001 From: prudh-vi Date: Fri, 30 Jan 2026 10:02:47 +0530 Subject: [PATCH 1/3] Add note about rand 0.9 API rename in guessing game chapter --- src/ch02-00-guessing-game-tutorial.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ch02-00-guessing-game-tutorial.md b/src/ch02-00-guessing-game-tutorial.md index 3c590a1994..54e2fd8c63 100644 --- a/src/ch02-00-guessing-game-tutorial.md +++ b/src/ch02-00-guessing-game-tutorial.md @@ -18,7 +18,7 @@ correct, the game will print a congratulatory message and exit. To set up a new project, go to the _projects_ directory that you created in Chapter 1 and make a new project using Cargo, like so: -```console +```consoleThe gen_range method $ cargo new guessing_game $ cd guessing_game ``` @@ -544,6 +544,13 @@ random number in the range. The kind of range expression we’re using here take the form `start..=end` and is inclusive on the lower and upper bounds, so we need to specify `1..=100` to request a number between 1 and 100. +> Note: If you are using `rand` version 0.9 or newer, some APIs have been renamed. +> In that case, the equivalent code looks like this: +> +> ```rust +> let secret_number = rand::rng().random_range(1..=100); +> ``` + > Note: You won’t just know which traits to use and which methods and functions > to call from a crate, so each crate has documentation with instructions for > using it. Another neat feature of Cargo is that running the `cargo doc From 31d6f8c01089c032fb4bf6774ede6774045f6d3c Mon Sep 17 00:00:00 2001 From: prudh-vi Date: Fri, 30 Jan 2026 10:19:08 +0530 Subject: [PATCH 2/3] Mark rand 0.9 example as ignored to avoid doctest failure --- src/ch02-00-guessing-game-tutorial.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ch02-00-guessing-game-tutorial.md b/src/ch02-00-guessing-game-tutorial.md index 54e2fd8c63..dd3da9b31b 100644 --- a/src/ch02-00-guessing-game-tutorial.md +++ b/src/ch02-00-guessing-game-tutorial.md @@ -18,7 +18,8 @@ correct, the game will print a congratulatory message and exit. To set up a new project, go to the _projects_ directory that you created in Chapter 1 and make a new project using Cargo, like so: -```consoleThe gen_range method +```console +The gen_range method $ cargo new guessing_game $ cd guessing_game ``` @@ -547,7 +548,7 @@ need to specify `1..=100` to request a number between 1 and 100. > Note: If you are using `rand` version 0.9 or newer, some APIs have been renamed. > In that case, the equivalent code looks like this: > -> ```rust +> ```rust,ignore > let secret_number = rand::rng().random_range(1..=100); > ``` From 7e8b02f2b1fbb188d3a36e80fc45c0198c631191 Mon Sep 17 00:00:00 2001 From: prudh-vi Date: Fri, 30 Jan 2026 10:31:39 +0530 Subject: [PATCH 3/3] Mark rand 0.9 example as ignored to avoid doctest failure --- src/ch02-00-guessing-game-tutorial.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ch02-00-guessing-game-tutorial.md b/src/ch02-00-guessing-game-tutorial.md index dd3da9b31b..2590c14414 100644 --- a/src/ch02-00-guessing-game-tutorial.md +++ b/src/ch02-00-guessing-game-tutorial.md @@ -19,7 +19,6 @@ To set up a new project, go to the _projects_ directory that you created in Chapter 1 and make a new project using Cargo, like so: ```console -The gen_range method $ cargo new guessing_game $ cd guessing_game ```