Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rand requirement from 0.8 to 0.9 #693

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions examples/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions examples/finebars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions examples/multi-tree-ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ fn get_action(rng: &mut dyn RngCore, items: &[&Item]) -> Action {
})
.map(|(idx, _)| idx)
.collect::<Vec<usize>>();
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);
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn get_action(rng: &mut dyn RngCore, tree: &Mutex<Vec<&Elem>>) -> Option<Action>
} 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 {
Expand Down
4 changes: 1 addition & 3 deletions examples/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ fn main() {
pb.inc(1);
let pb2 = pb2.clone();
threads.push(thread::spawn(move || {
thread::sleep(
rand::thread_rng().gen_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);
}));
}
Expand Down
10 changes: 5 additions & 5 deletions examples/yarnish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::{Duration, Instant};

use console::{style, Emoji};
use indicatif::{HumanDuration, MultiProgress, ProgressBar, ProgressStyle};
use rand::seq::SliceRandom;
use rand::prelude::IndexedRandom;
use rand::Rng;

static PACKAGES: &[&str] = &[
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}
Expand Down
Loading