Commit f984df9
authored
Update deprecated functions in
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
```Box::leak example1 parent e6ceffb commit f984df9
1 file changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
| 76 | + | |
| 77 | + | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
0 commit comments