Skip to content

Commit 2ca893b

Browse files
committed
Upgrade dev-deps to rand 0.9
1 parent 9319496 commit 2ca893b

File tree

19 files changed

+157
-98
lines changed

19 files changed

+157
-98
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ default-features = false
3535
web_spin_lock = ["dep:wasm_sync", "rayon-core/web_spin_lock"]
3636

3737
[dev-dependencies]
38-
rand = "0.8"
39-
rand_xorshift = "0.3"
38+
rand = "0.9"
39+
rand_xorshift = "0.4"

ci/compat-Cargo.lock

+71-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rayon-core/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ wasm_sync = { version = "0.1.0", optional = true }
3030
web_spin_lock = ["dep:wasm_sync"]
3131

3232
[dev-dependencies]
33-
rand = "0.8"
34-
rand_xorshift = "0.3"
33+
rand = "0.9"
34+
rand_xorshift = "0.4"
3535
scoped-tls = "1.0"
3636

3737
[target.'cfg(unix)'.dev-dependencies]

rayon-core/src/join/test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use super::*;
44
use crate::ThreadPoolBuilder;
5-
use rand::distributions::Standard;
5+
use rand::distr::StandardUniform;
66
use rand::{Rng, SeedableRng};
77
use rand_xorshift::XorShiftRng;
88

@@ -38,7 +38,7 @@ fn seeded_rng() -> XorShiftRng {
3838
#[test]
3939
fn sort() {
4040
let rng = seeded_rng();
41-
let mut data: Vec<u32> = rng.sample_iter(&Standard).take(6 * 1024).collect();
41+
let mut data: Vec<u32> = rng.sample_iter(&StandardUniform).take(6 * 1024).collect();
4242
let mut sorted_data = data.clone();
4343
sorted_data.sort();
4444
quick_sort(&mut data);
@@ -49,7 +49,7 @@ fn sort() {
4949
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
5050
fn sort_in_pool() {
5151
let rng = seeded_rng();
52-
let mut data: Vec<u32> = rng.sample_iter(&Standard).take(12 * 1024).collect();
52+
let mut data: Vec<u32> = rng.sample_iter(&StandardUniform).take(12 * 1024).collect();
5353

5454
let pool = ThreadPoolBuilder::new().build().unwrap();
5555
let mut sorted_data = data.clone();

rayon-core/src/scope/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ fn random_tree1(depth: usize, rng: &mut XorShiftRng) -> Tree<u32> {
119119
let children = if depth == 0 {
120120
vec![]
121121
} else {
122-
(0..rng.gen_range(0..4)) // somewhere between 0 and 3 children at each level
122+
(0..rng.random_range(0..4)) // somewhere between 0 and 3 children at each level
123123
.map(|_| random_tree1(depth - 1, rng))
124124
.collect()
125125
};
126126

127127
Tree {
128-
value: rng.gen_range(0..1_000_000),
128+
value: rng.random_range(0..1_000_000),
129129
children,
130130
}
131131
}

rayon-demo/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ docopt = "1"
1313
fixedbitset = "0.5"
1414
glium = "0.36"
1515
once_cell = "1.17.1"
16-
rand = "0.8"
17-
rand_xorshift = "0.3"
16+
rand = "0.9"
17+
rand_xorshift = "0.4"
1818
regex = "1"
1919
winit = "0.30"
2020

rayon-demo/src/find/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ macro_rules! make_tests {
44
($n:expr, $m:ident) => {
55
mod $m {
66
use once_cell::sync::Lazy;
7-
use rand::distributions::Standard;
7+
use rand::distr::StandardUniform;
88
use rand::Rng;
99
use rayon::prelude::*;
1010
use test::Bencher;
1111

1212
static HAYSTACK: Lazy<Box<[[u32; $n]]>> = Lazy::new(|| {
1313
let rng = crate::seeded_rng();
14-
rng.sample_iter(&Standard)
14+
rng.sample_iter(&StandardUniform)
1515
.map(|x| {
1616
let mut result: [u32; $n] = [0; $n];
1717
result[0] = x;

rayon-demo/src/life/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Options:
1616
";
1717

1818
use crate::cpu_time::{self, CpuMeasure};
19-
use rand::distributions::Standard;
20-
use rand::{thread_rng, Rng};
19+
use rand::distr::StandardUniform;
20+
use rand::{rng, Rng};
2121
use std::iter::repeat;
2222
use std::sync::Arc;
2323
use std::thread;
@@ -90,8 +90,8 @@ impl Board {
9090
}
9191

9292
pub fn random(&self) -> Board {
93-
let new_brd = thread_rng()
94-
.sample_iter(&Standard)
93+
let new_brd = rng()
94+
.sample_iter(&StandardUniform)
9595
.take(self.len())
9696
.collect();
9797

rayon-demo/src/mergesort/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rand::distributions::Standard;
1+
use rand::distr::StandardUniform;
22
use rand::Rng;
33

44
const USAGE: &str = "
@@ -236,7 +236,7 @@ pub fn is_sorted<T: Send + Ord>(v: &mut [T]) -> bool {
236236

237237
fn default_vec(n: usize) -> Vec<u32> {
238238
let rng = crate::seeded_rng();
239-
rng.sample_iter(&Standard).take(n).collect()
239+
rng.sample_iter(&StandardUniform).take(n).collect()
240240
}
241241

242242
fn timed_sort<F: FnOnce(&mut [u32])>(n: usize, f: F, name: &str) -> u64 {

rayon-demo/src/nbody/nbody.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,25 @@ impl NBodyBenchmark {
5252
pub fn new<R: Rng>(num_bodies: usize, rng: &mut R) -> NBodyBenchmark {
5353
let bodies0: Vec<_> = (0..num_bodies)
5454
.map(|_| {
55-
let r = rng.gen_range(0.0..10_000.0);
56-
let theta = rng.gen_range(0.0..PI);
57-
let phi = rng.gen_range(0.0..2.0 * PI);
55+
let r = rng.random_range(0.0..10_000.0);
56+
let theta = rng.random_range(0.0..PI);
57+
let phi = rng.random_range(0.0..2.0 * PI);
5858
let position = Point3 {
5959
x: r * theta.sin() * phi.cos(),
6060
y: r * theta.sin() * phi.sin(),
6161
z: r * theta.cos(),
6262
};
6363

6464
let velocity = Vector3 {
65-
x: rng.gen_range(-0.5..0.5) * INITIAL_VELOCITY,
66-
y: rng.gen_range(-0.5..0.5) * INITIAL_VELOCITY,
67-
z: rng.gen::<f64>() * INITIAL_VELOCITY + 10.0,
65+
x: rng.random_range(-0.5..0.5) * INITIAL_VELOCITY,
66+
y: rng.random_range(-0.5..0.5) * INITIAL_VELOCITY,
67+
z: rng.random::<f64>() * INITIAL_VELOCITY + 10.0,
6868
};
6969

7070
let velocity2 = Vector3 {
71-
x: rng.gen_range(-0.5..0.5) * INITIAL_VELOCITY,
72-
y: rng.gen_range(-0.5..0.5) * INITIAL_VELOCITY,
73-
z: rng.gen::<f64>() * INITIAL_VELOCITY,
71+
x: rng.random_range(-0.5..0.5) * INITIAL_VELOCITY,
72+
y: rng.random_range(-0.5..0.5) * INITIAL_VELOCITY,
73+
z: rng.random::<f64>() * INITIAL_VELOCITY,
7474
};
7575

7676
Body {

rayon-demo/src/nbody/visualize.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub fn visualize_benchmarks(num_bodies: usize, mode: ExecutionMode) {
191191
.with_title("nbody demo")
192192
.build(&event_loop);
193193

194-
let benchmark = NBodyBenchmark::new(num_bodies, &mut rand::thread_rng());
194+
let benchmark = NBodyBenchmark::new(num_bodies, &mut rand::rng());
195195

196196
let vertex_shader_src = r#"
197197
#version 100
@@ -231,9 +231,9 @@ pub fn visualize_benchmarks(num_bodies: usize, mode: ExecutionMode) {
231231
let instances: Vec<_> = (0..num_bodies)
232232
.map(|_| Instance {
233233
color: [
234-
rng.gen_range(0.5..1.0),
235-
rng.gen_range(0.5..1.0),
236-
rng.gen_range(0.5..1.0),
234+
rng.random_range(0.5..1.0),
235+
rng.random_range(0.5..1.0),
236+
rng.random_range(0.5..1.0),
237237
],
238238
world_position: [0.0, 0.0, 0.0],
239239
})

rayon-demo/src/quicksort/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct Args {
2323
}
2424

2525
use docopt::Docopt;
26-
use rand::distributions::Standard;
26+
use rand::distr::StandardUniform;
2727
use rand::Rng;
2828
use std::time::Instant;
2929

@@ -108,7 +108,7 @@ pub fn is_sorted<T: Send + Ord>(v: &[T]) -> bool {
108108

109109
fn default_vec(n: usize) -> Vec<u32> {
110110
let rng = crate::seeded_rng();
111-
rng.sample_iter(&Standard).take(n).collect()
111+
rng.sample_iter(&StandardUniform).take(n).collect()
112112
}
113113

114114
fn timed_sort<F: FnOnce(&mut [u32])>(n: usize, f: F, name: &str) -> u64 {

0 commit comments

Comments
 (0)