diff --git a/Cargo.lock b/Cargo.lock index 1de0bdb3..1c43e3d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -767,7 +767,7 @@ name = "demo" version = "0.0.0" dependencies = [ "clap", - "rand 0.8.5", + "rand 0.9.0", "ratatui", ] @@ -780,8 +780,8 @@ dependencies = [ "indoc", "itertools 0.13.0", "palette", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand 0.9.0", + "rand_chacha 0.9.0", "ratatui", "strum", "time", @@ -1110,10 +1110,22 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", +] + [[package]] name = "gimli" version = "0.28.1" @@ -1736,7 +1748,7 @@ checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -1747,7 +1759,7 @@ dependencies = [ "color-eyre", "crossterm", "line_drawing", - "rand 0.8.5", + "rand 0.9.0", "ratatui", ] @@ -2193,7 +2205,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -2281,11 +2293,20 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "libc", - "rand_chacha 0.3.1", "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.0", + "zerocopy 0.8.14", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -2298,12 +2319,12 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.3.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core 0.9.0", ] [[package]] @@ -2326,8 +2347,15 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "rand_core" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" dependencies = [ - "getrandom", + "getrandom 0.3.1", + "zerocopy 0.8.14", ] [[package]] @@ -2409,8 +2437,8 @@ dependencies = [ "itertools 0.13.0", "palette", "pretty_assertions", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand 0.9.0", + "rand_chacha 0.9.0", "ratatui-core", "ratatui-crossterm", "ratatui-termion", @@ -2559,7 +2587,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom", + "getrandom 0.2.15", "libredox", "thiserror 1.0.69", ] @@ -2622,7 +2650,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", "spin", "untrusted", @@ -3136,7 +3164,7 @@ checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", - "getrandom", + "getrandom 0.2.15", "once_cell", "rustix", "windows-sys 0.59.0", @@ -3621,7 +3649,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom", + "getrandom 0.2.15", ] [[package]] @@ -3631,7 +3659,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "744018581f9a3454a9e15beb8a33b017183f1e7c0cd170232a2d1453b23a51c4" dependencies = [ "atomic", - "getrandom", + "getrandom 0.2.15", ] [[package]] @@ -3680,6 +3708,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -3744,7 +3781,7 @@ version = "0.0.0" dependencies = [ "color-eyre", "crossterm", - "rand 0.8.5", + "rand 0.9.0", "ratatui", ] @@ -3785,7 +3822,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5a5e0adf7eed68976410def849a4bdab6f6e9f6163f152de9cb89deea9e60b" dependencies = [ - "getrandom", + "getrandom 0.2.15", "mac_address", "once_cell", "sha2", @@ -3972,6 +4009,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.8.0", +] + [[package]] name = "write16" version = "1.0.0" @@ -4036,7 +4082,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468" +dependencies = [ + "zerocopy-derive 0.8.14", ] [[package]] @@ -4050,6 +4105,17 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "zerocopy-derive" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", +] + [[package]] name = "zerofrom" version = "0.1.5" diff --git a/examples/apps/demo/Cargo.toml b/examples/apps/demo/Cargo.toml index a784332d..1734743e 100644 --- a/examples/apps/demo/Cargo.toml +++ b/examples/apps/demo/Cargo.toml @@ -13,5 +13,5 @@ termwiz = ["ratatui/termwiz"] [dependencies] clap = { version = "4.5.27", features = ["derive"] } -rand = "0.8.5" +rand = "0.9.0" ratatui.workspace = true diff --git a/examples/apps/demo/src/app.rs b/examples/apps/demo/src/app.rs index 84a80c4b..1f3226e0 100644 --- a/examples/apps/demo/src/app.rs +++ b/examples/apps/demo/src/app.rs @@ -1,5 +1,5 @@ use rand::{ - distributions::{Distribution, Uniform}, + distr::{Distribution, Uniform}, rngs::ThreadRng, }; use ratatui::widgets::ListState; @@ -75,8 +75,8 @@ pub struct RandomSignal { impl RandomSignal { pub fn new(lower: u64, upper: u64) -> Self { Self { - distribution: Uniform::new(lower, upper), - rng: rand::thread_rng(), + distribution: Uniform::new(lower, upper).expect("invalid range"), + rng: rand::rng(), } } } diff --git a/examples/apps/demo2/Cargo.toml b/examples/apps/demo2/Cargo.toml index 4bcc1784..c4e7193a 100644 --- a/examples/apps/demo2/Cargo.toml +++ b/examples/apps/demo2/Cargo.toml @@ -11,8 +11,8 @@ crossterm.workspace = true indoc.workspace = true itertools.workspace = true palette = "0.7.6" -rand = "0.8.5" -rand_chacha = "0.3.1" +rand = "0.9.0" +rand_chacha = "0.9.0" ratatui = { workspace = true, features = ["all-widgets"] } strum.workspace = true time = "0.3.37" diff --git a/examples/apps/demo2/src/destroy.rs b/examples/apps/demo2/src/destroy.rs index bc094fac..08c1af37 100644 --- a/examples/apps/demo2/src/destroy.rs +++ b/examples/apps/demo2/src/destroy.rs @@ -47,20 +47,20 @@ fn drip(frame_count: usize, area: Rect, buf: &mut Buffer) { let variable_speed = DRIP_SPEED as f64 * fractional_speed * fractional_speed * fractional_speed; let pixel_count = (frame_count as f64 * variable_speed).floor() as usize; for _ in 0..pixel_count { - let src_x = rng.gen_range(0..area.width); - let src_y = rng.gen_range(1..area.height - 2); + let src_x = rng.random_range(0..area.width); + let src_y = rng.random_range(1..area.height - 2); let src = buf[(src_x, src_y)].clone(); // 1% of the time, move a blank or pixel (10:1) to the top line of the screen - if rng.gen_ratio(1, 100) { + if rng.random_ratio(1, 100) { let dest_x = rng - .gen_range(src_x.saturating_sub(5)..src_x.saturating_add(5)) + .random_range(src_x.saturating_sub(5)..src_x.saturating_add(5)) .clamp(area.left(), area.right() - 1); let dest_y = area.top() + 1; let dest = &mut buf[(dest_x, dest_y)]; // copy the cell to the new location about 1/10 of the time blank out the cell the rest // of the time. This has the effect of gradually removing the pixels from the screen. - if rng.gen_ratio(1, 10) { + if rng.random_ratio(1, 10) { *dest = src; } else { dest.reset(); diff --git a/examples/apps/mouse-drawing/Cargo.toml b/examples/apps/mouse-drawing/Cargo.toml index a447e5aa..e501221a 100644 --- a/examples/apps/mouse-drawing/Cargo.toml +++ b/examples/apps/mouse-drawing/Cargo.toml @@ -10,7 +10,7 @@ color-eyre.workspace = true crossterm.workspace = true ## a collection of line drawing algorithms (e.g. Bresenham's line algorithm) line_drawing = "1.0.0" -rand = "0.8.5" +rand = "0.9.0" ratatui.workspace = true [lints] diff --git a/examples/apps/weather/Cargo.toml b/examples/apps/weather/Cargo.toml index c5fff68d..72925ad6 100644 --- a/examples/apps/weather/Cargo.toml +++ b/examples/apps/weather/Cargo.toml @@ -8,7 +8,7 @@ rust-version.workspace = true [dependencies] color-eyre.workspace = true crossterm.workspace = true -rand = "0.8.5" +rand = "0.9.0" ratatui.workspace = true [lints] diff --git a/examples/apps/weather/src/main.rs b/examples/apps/weather/src/main.rs index d76d945c..a160c643 100644 --- a/examples/apps/weather/src/main.rs +++ b/examples/apps/weather/src/main.rs @@ -9,7 +9,7 @@ //! [`BarChart`]: https://docs.rs/ratatui/latest/ratatui/widgets/struct.BarChart.html use color_eyre::Result; -use rand::{thread_rng, Rng}; +use rand::{rng, Rng}; use ratatui::{ crossterm::event::{self, Event, KeyCode, KeyEventKind}, layout::{Constraint, Layout}, @@ -34,8 +34,8 @@ struct App { impl App { fn new() -> Self { - let mut rng = thread_rng(); - let temperatures = (0..24).map(|_| rng.gen_range(50..90)).collect(); + let mut rng = rng(); + let temperatures = (0..24).map(|_| rng.random_range(50..90)).collect(); Self { should_exit: false, temperatures, diff --git a/ratatui/Cargo.toml b/ratatui/Cargo.toml index fc7ec3ef..f7354b13 100644 --- a/ratatui/Cargo.toml +++ b/ratatui/Cargo.toml @@ -123,8 +123,8 @@ font8x8 = "0.3.1" futures = "0.3.30" indoc = "2" pretty_assertions = "1.4.0" -rand = "0.8.5" -rand_chacha = "0.3.1" +rand = "0.9.0" +rand_chacha = "0.9.0" rstest = "0.24.0" serde_json.workspace = true tokio = { version = "1.43.0", features = ["rt", "macros", "time", "rt-multi-thread"] } diff --git a/ratatui/benches/main/barchart.rs b/ratatui/benches/main/barchart.rs index bed6c0d8..e220c7f8 100644 --- a/ratatui/benches/main/barchart.rs +++ b/ratatui/benches/main/barchart.rs @@ -9,14 +9,14 @@ use ratatui::{ /// Benchmark for rendering a barchart. fn barchart(c: &mut Criterion) { let mut group = c.benchmark_group("barchart"); - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); for data_count in [64, 256, 2048] { let data: Vec = (0..data_count) .map(|i| { Bar::default() .label(format!("B{i}")) - .value(rng.gen_range(0..data_count)) + .value(rng.random_range(0..data_count)) }) .collect(); diff --git a/ratatui/benches/main/sparkline.rs b/ratatui/benches/main/sparkline.rs index ebfda100..482c17bb 100644 --- a/ratatui/benches/main/sparkline.rs +++ b/ratatui/benches/main/sparkline.rs @@ -9,11 +9,11 @@ use ratatui::{ /// Benchmark for rendering a sparkline. fn sparkline(c: &mut Criterion) { let mut group = c.benchmark_group("sparkline"); - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); for data_count in [64, 256, 2048] { let data: Vec = (0..data_count) - .map(|_| rng.gen_range(0..data_count)) + .map(|_| rng.random_range(0..data_count)) .collect(); // Render a basic sparkline diff --git a/ratatui/examples/inline.rs b/ratatui/examples/inline.rs index c71df892..59d976c5 100644 --- a/ratatui/examples/inline.rs +++ b/ratatui/examples/inline.rs @@ -21,7 +21,7 @@ use std::{ }; use color_eyre::Result; -use rand::distributions::{Distribution, Uniform}; +use rand::distr::{Distribution, Uniform}; use ratatui::{ backend::Backend, crossterm::event, @@ -152,8 +152,8 @@ fn workers(tx: mpsc::Sender) -> Vec { } fn downloads() -> Downloads { - let distribution = Uniform::new(0, 1000); - let mut rng = rand::thread_rng(); + let distribution = Uniform::new(0, 1000).expect("invalid range"); + let mut rng = rand::rng(); let pending = (0..NUM_DOWNLOADS) .map(|id| { let size = distribution.sample(&mut rng);