From f0f335bdf75f11d49f6fe59590b6a29d005feabc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 19:18:39 +0000 Subject: [PATCH 1/3] Update rand requirement from 0.8 to 0.9 Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.8.0...0.9.0) --- updated-dependencies: - dependency-name: rand dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index aa1878b3..bd263cab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ vt100 = { version = "0.15.1", optional = true } [dev-dependencies] clap = { version = "4", features = ["color", "derive"] } once_cell = "1" -rand = "0.8" +rand = "0.9" tokio = { version = "1", features = ["fs", "time", "rt"] } futures = "0.3" # so the doctest for wrap_stream is nice pretty_assertions = "1.4.0" From 20e73c475f68ac58e89984f340324e0d19f4e0a9 Mon Sep 17 00:00:00 2001 From: Chris Laplante Date: Mon, 27 Jan 2025 14:38:14 -0500 Subject: [PATCH 2/3] Apply breaking fixes for the rand 0.8 => 0.9 upgrade --- examples/cargo.rs | 6 +++--- examples/finebars.rs | 4 ++-- examples/multi-tree-ext.rs | 4 ++-- examples/multi-tree.rs | 2 +- examples/multi.rs | 2 +- examples/yarnish.rs | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/cargo.rs b/examples/cargo.rs index 1e2ff2e9..e29f7fe7 100644 --- a/examples/cargo.rs +++ b/examples/cargo.rs @@ -64,7 +64,7 @@ fn main() { let tx = tx.clone(); let crates = crates.clone(); thread::spawn(move || { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); loop { let krate = crates.lock().unwrap().next(); // notify main thread if n thread is processing a crate @@ -73,9 +73,9 @@ fn main() { thread::sleep(Duration::from_millis( // last compile and linking is always slow, let's mimic that if CRATES.last() == Some(krate) { - rng.gen_range(1_000..2_000) + rng.random_range(1_000..2_000) } else { - rng.gen_range(250..1_000) + rng.random_range(250..1_000) }, )); } else { diff --git a/examples/finebars.rs b/examples/finebars.rs index dffb967b..06a1a2dc 100644 --- a/examples/finebars.rs +++ b/examples/finebars.rs @@ -2,7 +2,7 @@ use std::thread; use std::time::Duration; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use rand::{thread_rng, Rng}; +use rand::Rng; fn main() { let styles = [ @@ -25,7 +25,7 @@ fn main() { .progress_chars(s.1), ); pb.set_prefix(s.0); - let wait = Duration::from_millis(thread_rng().gen_range(10..30)); + let wait = Duration::from_millis(rand::rng().random_range(10..30)); thread::spawn(move || { for i in 0..512 { thread::sleep(wait); diff --git a/examples/multi-tree-ext.rs b/examples/multi-tree-ext.rs index 06515489..b769f381 100644 --- a/examples/multi-tree-ext.rs +++ b/examples/multi-tree-ext.rs @@ -266,9 +266,9 @@ fn get_action(rng: &mut dyn RngCore, items: &[&Item]) -> Action { }) .map(|(idx, _)| idx) .collect::>(); - let k = rng.gen_range(0..16); + let k = rng.random_range(0..16); if (k > 0 || k == 0 && elem_idx == ELEMENTS.len()) && !uncompleted.is_empty() { - let idx = rng.gen_range(0..uncompleted.len() as u64) as usize; + let idx = rng.random_range(0..uncompleted.len() as u64) as usize; Action::IncProgressBar(uncompleted[idx]) } else if elem_idx < ELEMENTS.len() { ELEM_IDX.fetch_add(1, Ordering::SeqCst); diff --git a/examples/multi-tree.rs b/examples/multi-tree.rs index 3435424a..ac1f0609 100644 --- a/examples/multi-tree.rs +++ b/examples/multi-tree.rs @@ -173,7 +173,7 @@ fn get_action(rng: &mut dyn RngCore, tree: &Mutex>) -> Option } else { loop { let list = tree.lock().unwrap(); - let k = rng.gen_range(0..17); + let k = rng.random_range(0..17); if k == 0 && list_len < elem_len { return Some(Action::AddProgressBar(list.len())); } else { diff --git a/examples/multi.rs b/examples/multi.rs index dfb71ff0..cf34c562 100644 --- a/examples/multi.rs +++ b/examples/multi.rs @@ -48,7 +48,7 @@ fn main() { let pb2 = pb2.clone(); threads.push(thread::spawn(move || { thread::sleep( - rand::thread_rng().gen_range(Duration::from_secs(1)..Duration::from_secs(5)), + rand::rng().random_range(Duration::from_secs(1)..Duration::from_secs(5)), ); pb2.inc(1); })); diff --git a/examples/yarnish.rs b/examples/yarnish.rs index 6b7c29b1..9e5c5132 100644 --- a/examples/yarnish.rs +++ b/examples/yarnish.rs @@ -3,8 +3,8 @@ use std::time::{Duration, Instant}; use console::{style, Emoji}; use indicatif::{HumanDuration, MultiProgress, ProgressBar, ProgressStyle}; -use rand::seq::SliceRandom; use rand::Rng; +use rand::prelude::IndexedRandom; static PACKAGES: &[&str] = &[ "fs-events", @@ -33,7 +33,7 @@ static PAPER: Emoji<'_, '_> = Emoji("📃 ", ""); static SPARKLE: Emoji<'_, '_> = Emoji("✨ ", ":-)"); pub fn main() { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let started = Instant::now(); let spinner_style = ProgressStyle::with_template("{prefix:.bold.dim} {spinner} {wide_msg}") .unwrap() @@ -71,16 +71,16 @@ pub fn main() { let m = MultiProgress::new(); let handles: Vec<_> = (0..4u32) .map(|i| { - let count = rng.gen_range(30..80); + let count = rng.random_range(30..80); let pb = m.add(ProgressBar::new(count)); pb.set_style(spinner_style.clone()); pb.set_prefix(format!("[{}/?]", i + 1)); thread::spawn(move || { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let pkg = PACKAGES.choose(&mut rng).unwrap(); for _ in 0..count { let cmd = COMMANDS.choose(&mut rng).unwrap(); - thread::sleep(Duration::from_millis(rng.gen_range(25..200))); + thread::sleep(Duration::from_millis(rng.random_range(25..200))); pb.set_message(format!("{pkg}: {cmd}")); pb.inc(1); } From 6b1965aa0e1026d118fc8689814dfbda276d32e1 Mon Sep 17 00:00:00 2001 From: Chris Laplante Date: Mon, 27 Jan 2025 14:41:55 -0500 Subject: [PATCH 3/3] cargo fmt --- examples/multi.rs | 4 +--- examples/yarnish.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/multi.rs b/examples/multi.rs index cf34c562..4a7eb536 100644 --- a/examples/multi.rs +++ b/examples/multi.rs @@ -47,9 +47,7 @@ fn main() { pb.inc(1); let pb2 = pb2.clone(); threads.push(thread::spawn(move || { - thread::sleep( - rand::rng().random_range(Duration::from_secs(1)..Duration::from_secs(5)), - ); + thread::sleep(rand::rng().random_range(Duration::from_secs(1)..Duration::from_secs(5))); pb2.inc(1); })); } diff --git a/examples/yarnish.rs b/examples/yarnish.rs index 9e5c5132..129c0f5b 100644 --- a/examples/yarnish.rs +++ b/examples/yarnish.rs @@ -3,8 +3,8 @@ use std::time::{Duration, Instant}; use console::{style, Emoji}; use indicatif::{HumanDuration, MultiProgress, ProgressBar, ProgressStyle}; -use rand::Rng; use rand::prelude::IndexedRandom; +use rand::Rng; static PACKAGES: &[&str] = &[ "fs-events",