From 83a16fe9bbb017703a4df065e7b763bb0e6e19a8 Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Sat, 8 Mar 2025 10:01:11 +0100 Subject: [PATCH] update to new random --- src/color.rs | 12 ++++++------ src/stream.rs | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/color.rs b/src/color.rs index b372a72..04cd380 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,6 +1,6 @@ use std::fmt::Display; -use rand::{distributions::Standard, prelude::Distribution}; +use rand::{distr::StandardUniform, prelude::Distribution}; #[derive(Debug, PartialEq)] pub enum Color { @@ -19,13 +19,13 @@ impl Display for Color { } } -impl Distribution for Standard { +impl Distribution for StandardUniform { fn sample(&self, rng: &mut R) -> Color { - let index: u8 = rng.gen_range(0..3); + let index: u8 = rng.random_range(0..3); match index { - 0 => Color::W8(rng.gen()), - 1 => Color::RGB24(rng.gen(), rng.gen(), rng.gen()), - 2 => Color::RGBA32(rng.gen(), rng.gen(), rng.gen(), rng.gen()), + 0 => Color::W8(rng.random()), + 1 => Color::RGB24(rng.random(), rng.random(), rng.random()), + 2 => Color::RGBA32(rng.random(), rng.random(), rng.random(), rng.random()), _ => unreachable!(), } } diff --git a/src/stream.rs b/src/stream.rs index 45b6686..3e6b0b1 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -1,7 +1,7 @@ use axum::http::{self, HeaderMap, HeaderValue}; use axum_streams::StreamingFormat; use futures::StreamExt; -use rand::{distributions::Standard, thread_rng, Rng}; +use rand::{distr::StandardUniform, rng, Rng}; pub(crate) struct Multipart { first: bool, @@ -11,8 +11,8 @@ pub(crate) struct Multipart { impl Multipart { pub(crate) fn new(boundary_length: usize, headers: HeaderMap) -> Self { - let boundary = thread_rng() - .sample_iter(Standard) + let boundary = rng() + .sample_iter(StandardUniform) .filter(|c| match c { 32..127 | 128..=255 => true, 0..32 | 127 => false,