diff options
| author | Eric Huss <eric@huss.org> | 2025-02-13 12:20:55 -0800 |
|---|---|---|
| committer | Eric Huss <eric@huss.org> | 2025-02-13 12:20:55 -0800 |
| commit | b7c975b22e557e41c5110006c371018ef310691a (patch) | |
| tree | ecf204bb14a09f16f1c3b2940c2c775f11a19fb7 /library/alloc/tests/sort | |
| parent | ef34064679afd2e307dc0b3aff2023b668e12ac7 (diff) | |
| download | rust-b7c975b22e557e41c5110006c371018ef310691a.tar.gz rust-b7c975b22e557e41c5110006c371018ef310691a.zip | |
library: Update rand to 0.9.0
Diffstat (limited to 'library/alloc/tests/sort')
| -rw-r--r-- | library/alloc/tests/sort/patterns.rs | 8 | ||||
| -rw-r--r-- | library/alloc/tests/sort/zipf.rs | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/library/alloc/tests/sort/patterns.rs b/library/alloc/tests/sort/patterns.rs index e5d31d868b2..0f1ec664d3d 100644 --- a/library/alloc/tests/sort/patterns.rs +++ b/library/alloc/tests/sort/patterns.rs @@ -1,8 +1,8 @@ use std::env; -use std::hash::Hash; use std::str::FromStr; use std::sync::OnceLock; +use rand::distr::Uniform; use rand::prelude::*; use rand_xorshift::XorShiftRng; @@ -23,14 +23,14 @@ pub fn random(len: usize) -> Vec<i32> { pub fn random_uniform<R>(len: usize, range: R) -> Vec<i32> where - R: Into<rand::distributions::Uniform<i32>> + Hash, + Uniform<i32>: TryFrom<R, Error: std::fmt::Debug>, { // :.:.:.:: let mut rng: XorShiftRng = rand::SeedableRng::seed_from_u64(get_or_init_rand_seed()); // Abstracting over ranges in Rust :( - let dist: rand::distributions::Uniform<i32> = range.into(); + let dist = Uniform::try_from(range).unwrap(); (0..len).map(|_| dist.sample(&mut rng)).collect() } @@ -207,5 +207,5 @@ fn rand_root_seed() -> u64 { fn random_vec(len: usize) -> Vec<i32> { let mut rng: XorShiftRng = rand::SeedableRng::seed_from_u64(get_or_init_rand_seed()); - (0..len).map(|_| rng.gen::<i32>()).collect() + (0..len).map(|_| rng.random::<i32>()).collect() } diff --git a/library/alloc/tests/sort/zipf.rs b/library/alloc/tests/sort/zipf.rs index cc774ee5c43..3dad2db521f 100644 --- a/library/alloc/tests/sort/zipf.rs +++ b/library/alloc/tests/sort/zipf.rs @@ -80,7 +80,7 @@ impl ZipfDistribution { loop { use std::cmp; - let u: f64 = hnum + rng.gen::<f64>() * (self.h_integral_x1 - hnum); + let u: f64 = hnum + rng.random::<f64>() * (self.h_integral_x1 - hnum); // u is uniformly distributed in (h_integral_x1, h_integral_num_elements] let x: f64 = ZipfDistribution::h_integral_inv(u, self.exponent); @@ -145,7 +145,7 @@ impl ZipfDistribution { } } -impl rand::distributions::Distribution<usize> for ZipfDistribution { +impl rand::distr::Distribution<usize> for ZipfDistribution { fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize { self.next(rng) } |
