Skip to content

Update chapter02.md#4344

Closed
MajesticTwelve12 wants to merge 1 commit intorust-lang:mainfrom
MajesticTwelve12:main
Closed

Update chapter02.md#4344
MajesticTwelve12 wants to merge 1 commit intorust-lang:mainfrom
MajesticTwelve12:main

Conversation

@MajesticTwelve12
Copy link
Copy Markdown

Changed let secret_number = rand::thread_rng().gen_range(1..=100); and gen_range() are depracted since 0.9.0 and should use let secret_number = rand::rng().random_range(1..=100);

Sources

https://docs.rs/rand/latest/rand/fn.thread_rng.html
https://docs.rs/rand/latest/rand/trait.Rng.html#method.gen_range

Changed ` let secret_number = rand::thread_rng().gen_range(1..=100);` and gen_range() are depracted since 0.9.0 and should use `let secret_number = rand::rng().random_range(1..=100);`
    
    Sources
    
    https://docs.rs/rand/latest/rand/fn.thread_rng.html
    https://docs.rs/rand/latest/rand/trait.Rng.html#method.gen_range
blundster

This comment was marked as outdated.

@dnetguru
Copy link
Copy Markdown

I think this is important to merge since the introduction states:

This version of the text assumes you’re using Rust 1.85.0 (released 2025-02-17) or later with edition = "2024"

and these changes to the rand library were made due to conflicts with newly reserved gen keyword in the 2024 edition.

However, the earlier section adding rand = "0.8.5" as a dependency and later upgrading it to rand = "0.9.0" should probably be also modified not to cross the 0.9.0 version since that is where the rename took effect (along with the relevant outputs of cargo build and cargo update runs). It could use 0.9.0 initially and later upgrade to 0.9.2 as an example.

@carols10cents
Copy link
Copy Markdown
Member

This is a duplicate of #4254. Thanks though!

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