Skip to content

Commit c5cd6c6

Browse files
authored
Merge pull request #1992 from anselbobrow/patch-1
Update deprecated functions in `Box::leak` example
2 parents fca9177 + f984df9 commit c5cd6c6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/scope/lifetime/static_lifetime.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ live for the entire duration, but only from the leaking point onward.
7373
extern crate rand;
7474
use rand::Fill;
7575
76-
fn random_vec() -> &'static [usize; 100] {
77-
let mut rng = rand::thread_rng();
76+
fn random_vec() -> &'static [u64; 100] {
77+
let mut rng = rand::rng();
7878
let mut boxed = Box::new([0; 100]);
79-
boxed.try_fill(&mut rng).unwrap();
79+
boxed.fill(&mut rng);
8080
Box::leak(boxed)
8181
}
8282
8383
fn main() {
84-
let first: &'static [usize; 100] = random_vec();
85-
let second: &'static [usize; 100] = random_vec();
84+
let first: &'static [u64; 100] = random_vec();
85+
let second: &'static [u64; 100] = random_vec();
8686
assert_ne!(first, second)
8787
}
8888
```

0 commit comments

Comments
 (0)