-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Update deprecated functions in Box::leak example
#1992
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously, this example wasn't compiling because of the deprecated `thread_rng` and `fill` functions. Upon making the changes the compiler suggests and swapping `usize` for `u64`, the example compiles properly. Here are the compile errors:
```sh
Compiling playground v0.0.1 (/playground)
warning: unused import: `rand::Fill`
--> src/main.rs:2:5
|
2 | use rand::Fill;
| ^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default
warning: use of deprecated function `rand::thread_rng`: Renamed to `rng`
--> src/main.rs:5:25
|
5 | let mut rng = rand::thread_rng();
| ^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
error[E0599]: no method named `try_fill` found for struct `Box<[{integer}; 100]>` in the current scope
--> src/main.rs:7:11
|
7 | boxed.try_fill(&mut rng).unwrap();
| ^^^^^^^^
|
help: there is a method `fill` with a similar name
|
7 - boxed.try_fill(&mut rng).unwrap();
7 + boxed.fill(&mut rng).unwrap();
|
For more information about this error, try `rustc --explain E0599`.
warning: `playground` (bin "playground") generated 2 warnings
error: could not compile `playground` (bin "playground") due to 1 previous error; 2 warnings emitted
```
Collaborator
|
r? @marioidival rustbot has assigned @marioidival. Use |
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jan 26, 2026
Update books ## rust-lang/reference 5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a 2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC - Rename the ".general" rules (rust-lang/reference#2133) - Unwrap more chapters (rust-lang/reference#2134) - Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132) - Fix spacing with ordered lists (rust-lang/reference#2131) - Reflect explicit macro import in reference (rust-lang/reference#2077) ## rust-lang/rust-by-example 6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20 2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC - Update supertraits.md (rust-lang/rust-by-example#1988) - Update question_mark.md (rust-lang/rust-by-example#1990) - Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992) - Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993) - Fix typo (rust-lang/rust-by-example#1986) - Korean translation! (rust-lang/rust-by-example#1985)
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jan 26, 2026
Update books ## rust-lang/reference 5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a 2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC - Rename the ".general" rules (rust-lang/reference#2133) - Unwrap more chapters (rust-lang/reference#2134) - Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132) - Fix spacing with ordered lists (rust-lang/reference#2131) - Reflect explicit macro import in reference (rust-lang/reference#2077) ## rust-lang/rust-by-example 6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20 2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC - Update supertraits.md (rust-lang/rust-by-example#1988) - Update question_mark.md (rust-lang/rust-by-example#1990) - Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992) - Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993) - Fix typo (rust-lang/rust-by-example#1986) - Korean translation! (rust-lang/rust-by-example#1985)
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jan 26, 2026
Update books ## rust-lang/reference 5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a 2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC - Rename the ".general" rules (rust-lang/reference#2133) - Unwrap more chapters (rust-lang/reference#2134) - Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132) - Fix spacing with ordered lists (rust-lang/reference#2131) - Reflect explicit macro import in reference (rust-lang/reference#2077) ## rust-lang/rust-by-example 6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20 2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC - Update supertraits.md (rust-lang/rust-by-example#1988) - Update question_mark.md (rust-lang/rust-by-example#1990) - Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992) - Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993) - Fix typo (rust-lang/rust-by-example#1986) - Korean translation! (rust-lang/rust-by-example#1985)
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Jan 27, 2026
Update books ## rust-lang/reference 5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a 2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC - Rename the ".general" rules (rust-lang/reference#2133) - Unwrap more chapters (rust-lang/reference#2134) - Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132) - Fix spacing with ordered lists (rust-lang/reference#2131) - Reflect explicit macro import in reference (rust-lang/reference#2077) ## rust-lang/rust-by-example 6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20 2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC - Update supertraits.md (rust-lang/rust-by-example#1988) - Update question_mark.md (rust-lang/rust-by-example#1990) - Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992) - Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993) - Fix typo (rust-lang/rust-by-example#1986) - Korean translation! (rust-lang/rust-by-example#1985)
rust-timer
added a commit
to rust-lang/rust
that referenced
this pull request
Jan 27, 2026
Rollup merge of #151699 - rustbot:docs-update, r=ehuss Update books ## rust-lang/reference 5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a 2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC - Rename the ".general" rules (rust-lang/reference#2133) - Unwrap more chapters (rust-lang/reference#2134) - Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132) - Fix spacing with ordered lists (rust-lang/reference#2131) - Reflect explicit macro import in reference (rust-lang/reference#2077) ## rust-lang/rust-by-example 6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20 2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC - Update supertraits.md (rust-lang/rust-by-example#1988) - Update question_mark.md (rust-lang/rust-by-example#1990) - Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992) - Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993) - Fix typo (rust-lang/rust-by-example#1986) - Korean translation! (rust-lang/rust-by-example#1985)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1922
Previously, this example wasn't compiling because of the deprecated
thread_rngandfillfunctions. Upon making the changes the compiler suggests and swappingusizeforu64, the example compiles properly. Here are the compiler errors: