update to new random

This commit is contained in:
Noa Aarts 2025-03-08 10:01:11 +01:00
parent edc060338d
commit 83a16fe9bb
Signed by: noa
GPG key ID: 1850932741EFF672
2 changed files with 9 additions and 9 deletions

View file

@ -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<Color> for Standard {
impl Distribution<Color> for StandardUniform {
fn sample<R: rand::Rng + ?Sized>(&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!(),
}
}

View file

@ -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,