Skip to content

Commit 1d55a97

Browse files
authored
Merge pull request #1240 from TheIronBorn/patch-13
small deterministic example update
2 parents 330efe9 + 89d7e4e commit 1d55a97

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

examples/rayon-monte-carlo.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ fn main() {
5555
.into_par_iter()
5656
.map(|i| {
5757
let mut rng = ChaCha8Rng::seed_from_u64(SEED);
58-
// We chose ChaCha because it's fast, has suitable statical properties for simulation,
59-
// and because it supports this set_stream() api, which lets us chose a different stream
58+
// We chose ChaCha because it's fast, has suitable statistical properties for simulation,
59+
// and because it supports this set_stream() api, which lets us choose a different stream
6060
// per work item. ChaCha supports 2^64 independent streams.
6161
rng.set_stream(i);
6262
let mut count = 0;
@@ -69,7 +69,10 @@ fn main() {
6969
}
7070
count
7171
})
72-
.reduce(|| 0usize, |a, b| a + b);
72+
.sum::<usize>();
73+
74+
// assert this is deterministic
75+
assert_eq!(in_circle, 7852263);
7376

7477
// prints something close to 3.14159...
7578
println!(

0 commit comments

Comments
 (0)