From 9529f64b41ba6879942ee0e6dff2c7007d94e771 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Thu, 17 Sep 2026 16:43:01 +0800 Subject: [PATCH] fix(send): migrate rand usage to the 0.10 API rand 0.10 renamed the entry points dependabot's version bump alone cannot follow: `thread_rng()` -> `rng()`, `gen_range()` -> `random_range()` and the `Rng` trait -> `RngExt`. The jitter only needs one float, so use the free function `rand::random_range(0.2..0.8)` and drop the now-unused trait import instead of importing `RngExt`. Verified: cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace --locked (retry_delay_seconds_bounds keeps the 0.2..0.8 jitter window). --- crates/xmedia-bot/src/send/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/xmedia-bot/src/send/mod.rs b/crates/xmedia-bot/src/send/mod.rs index abafe91..544c1c6 100644 --- a/crates/xmedia-bot/src/send/mod.rs +++ b/crates/xmedia-bot/src/send/mod.rs @@ -17,7 +17,6 @@ use crate::link_cache::{CachedMedia, CachedMediaKind, CachedPost}; use crate::media_sender::MediaSender; use input_media::{build_media_group, input_file_for, item_url}; use post_send::{cache_animation_send, cache_sent_task}; -use rand::Rng; use serde::{Deserialize, Serialize}; use std::sync::LazyLock; use teloxide::prelude::*; @@ -261,7 +260,7 @@ pub fn photos_first(items: Vec) -> Vec { /// Exponential backoff with jitter, capped at 30s. pub fn retry_delay_seconds(attempts: u32) -> f64 { - let jitter: f64 = rand::thread_rng().gen_range(0.2..0.8); + let jitter: f64 = rand::random_range(0.2..0.8); (2f64.powi(attempts as i32) + jitter).min(30.0) }