Skip to content

Update to use rand 0.9 throughout#4254

Open
chuksgpfr wants to merge 2 commits intorust-lang:mainfrom
chuksgpfr:chore/rand_version
Open

Update to use rand 0.9 throughout#4254
chuksgpfr wants to merge 2 commits intorust-lang:mainfrom
chuksgpfr:chore/rand_version

Conversation

@chuksgpfr
Copy link
Copy Markdown

Chapter 2. Programming a Guessing Game uses thread_rng() and gen_range(), which are deprecated.
I replaced every thread_rng() with rng(), and every gen_range() with random_range()

The function is also referenced in a few other areas, of which I updated.

Since this issue HERE was closed

@chuksgpfr chuksgpfr changed the title Use non deprecated functions in Chapter 2. Programming a Guessing Game Update to use rand 0.9 throughout Mar 2, 2025
@chuksgpfr
Copy link
Copy Markdown
Author

@chriskrycho any possibility for this merge, seems quite some people get thrown off when this does not work their way.

@Ahorts
Copy link
Copy Markdown

Ahorts commented Jun 14, 2025

I was just thinking of opening a PR on this. I wonder why this hasn't been reviewed and merged yet.

@chuksgpfr
Copy link
Copy Markdown
Author

I was just thinking of opening a PR on this. I wonder why this hasn't been reviewed and merged yet.

@chriskrycho People are waiting for this.

@carols10cents
Copy link
Copy Markdown
Member

We're currently working on updating the print version, and updating the rand crate is not going to be part of that. Once we're done with that work, we'll review this.

New versions of rand being released are why we have this note:

Be sure to specify rand exactly as we have here, with this version number, or the code examples in this tutorial
may not work:

If people follow the instructions, there should be no problems.

@552020
Copy link
Copy Markdown

552020 commented Jul 11, 2025

We're currently working on updating the print version, and updating the rand crate is not going to be part of that. Once we're done with that work, we'll review this.

New versions of rand being released are why we have this note:

Be sure to specify rand exactly as we have here, with this version number, or the code examples in this tutorial
may not work:

If people follow the instructions, there should be no problems.

I'm not sure what you mean. Following exactly the instructions of the book (online), "specifyingrand exactly as we have here", doesn't give the same result as in the book because of the deprecation. I mean: you get the same result but you get also the warnings.

@carols10cents
Copy link
Copy Markdown
Member

mean: you get the same result but you get also the warnings.

As you said, you get the same result -- the functionality of the program is not affected. Warnings are just fine, as we state here:

compile will continue to compile with newer Rust versions. The output might
differ slightly between versions because Rust often improves error messages and
warnings. In other words, any newer, stable version of Rust you install using

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.

4 participants