Skip to content

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

Closed
TexanDoomGuy wants to merge 13 commits into
rust-lang:mainfrom
TexanDoomGuy:main
Closed

Use non deprecated functions in Chapter 2. Programming a Guessing Game#4217
TexanDoomGuy wants to merge 13 commits into
rust-lang:mainfrom
TexanDoomGuy:main

Conversation

@TexanDoomGuy
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.

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

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
Copy Markdown
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
Copy Markdown
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.

@TexanDoomGuy
Copy link
Copy Markdown
Author

Sorry, I've been a little busy. I'll get that done soon.

@TexanDoomGuy
Copy link
Copy Markdown
Author

I don't think I can have time for this currently. I've gotten a lot of work from school.

@chuksgpfr
Copy link
Copy Markdown

@chriskrycho I opened a new PR for this HERE

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