You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide-test-fn-rng.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@
3
3
Occasionally a function that uses random number generators might need to be tested. For functions that need to be tested with test vectors, the following approach might be adapted:
Copy file name to clipboardExpand all lines: src/update-0.10.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Users of `rand` will often need to import `rand::RngExt` may need to migrate fro
26
26
27
27
`rand_core::OsRng` has been replaced with `getrandom::SysRng` (also available as `rand::rngs::SysRng`).
28
28
29
-
The methods `SeedableRng::from_os_rng` and `try_from_os_rng` have thus been removed. `rand::make_rng()` is provided as a partial replacement; otherwise use `SomeRng::try_from_rng(&mut SysRng).unwrap()`.
29
+
The methods `SeedableRng::from_os_rng` and `try_from_os_rng` have thus been removed. [`rand::make_rng()`] is provided as a partial replacement; otherwise use `SomeRng::try_from_rng(&mut SysRng).unwrap()`.
30
30
31
31
32
32
## PRNGs
@@ -41,10 +41,10 @@ Other PRNG crates have been updated with minimal changes (though this may not re
41
41
42
42
`StdRng` and `ChaCha{8,12,20}Rng` no longer implement `Clone` or the [serde] traits. This was a deliberate choice to prevent accidental key-stream duplication or persisting to external storage. Note that it remains possible to clone or serialize these RNGs by reconstructing a new instance with the same key, then setting the stream (if applicable) and word position. For example:
43
43
```rust,editable
44
-
use rand::{rngs::ChaCha8Rng, Rng};
44
+
use rand::{rngs::ChaCha8Rng, Rng, SeedableRng};
45
45
46
46
let mut rng1: ChaCha8Rng = rand::make_rng();
47
-
let _: u128 = rng1.next_u64();
47
+
let _ = rng1.next_u64();
48
48
49
49
let mut rng2 = ChaCha8Rng::from_seed(rng1.get_seed());
50
50
rng2.set_stream(rng1.get_stream());
@@ -85,3 +85,4 @@ There are no known value-breaking changes to `rand` in v0.10.
0 commit comments