Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use non deprecated functions in Chapter 2. Programming a Guessing Game #4217

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

TexanDoomGuy
Copy link

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.

@TexanDoomGuy TexanDoomGuy marked this pull request as ready for review January 29, 2025 21:22
@Fnige
Copy link

Fnige commented Jan 30, 2025

Dont forget to update the rand version shown in the chapter too along with the cargo build output

@chriskrycho
Copy link
Contributor

Thank you! I’ll take a look at this later this week as part of my work to prepare the book for the 2024 Edition release!

Copy link
Contributor

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are solid—thank you! We need a few more to be able to land this:

  1. A better title for this is “Update to use rand 0.9 throughout”. Those functions are not deprecated on the version that the book is using, after all!

  2. We do indeed need to update all instances of rand = "0.8.5" to rand = "0.9.0" in the Cargo.toml files throughout.1 That includes in the text immediately after including Listing 2-2, which itself shows adding rand to the Cargo.toml file.

    That will also flag up the need for some changes in Chapter 14!

  3. We also need to update the sections Ensuring Reproducible Builds with the Cargo.lock File and Updating a Crate to Get a New Version in Ch. 2 to use 0.9.0 as the starting point and 0.9.1 and 0.10.0 as the “new versions” in the text, in the manual-regeneration comment, and in the code samples.

Footnotes

  1. It’s quite surprising to me that this is passing CI at the moment! But that’s an issue with something about how we’re running mdbook test and not specific to this PR. I will follow up on that in parallel to our landing this.

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.

3 participants