From 368b9ef7353af51639b83dc404b0c86ecaf6b553 Mon Sep 17 00:00:00 2001 From: amtoaer Date: Sat, 11 Jan 2025 23:36:59 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E6=B8=85=E7=A9=BA=20clippy=20?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/bili_sync/src/bilibili/client.rs | 21 +++++++++++---------- crates/bili_sync/src/bilibili/video.rs | 2 +- crates/bili_sync/src/config/global.rs | 2 +- crates/bili_sync/src/utils/nfo.rs | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/crates/bili_sync/src/bilibili/client.rs b/crates/bili_sync/src/bilibili/client.rs index 80097aa..4810646 100644 --- a/crates/bili_sync/src/bilibili/client.rs +++ b/crates/bili_sync/src/bilibili/client.rs @@ -69,17 +69,18 @@ pub struct BiliClient { impl BiliClient { pub fn new() -> Self { let client = Client::new(); - let limiter = match CONFIG.concurrent_limit.rate_limit { - Some(RateLimit { limit, duration }) => Some( + let limiter = CONFIG + .concurrent_limit + .rate_limit + .as_ref() + .map(|RateLimit { limit, duration }| { RateLimiter::builder() - .initial(limit) - .refill(limit) - .max(limit) - .interval(Duration::from_secs(duration)) - .build(), - ), - None => None, - }; + .initial(*limit) + .refill(*limit) + .max(*limit) + .interval(Duration::from_secs(*duration)) + .build() + }); Self { client, limiter } } diff --git a/crates/bili_sync/src/bilibili/video.rs b/crates/bili_sync/src/bilibili/video.rs index e0f9744..caa07a6 100644 --- a/crates/bili_sync/src/bilibili/video.rs +++ b/crates/bili_sync/src/bilibili/video.rs @@ -130,7 +130,7 @@ impl<'a> Video<'a> { .error_for_status()?; let headers = std::mem::take(res.headers_mut()); let content_type = headers.get("content-type"); - if !content_type.is_some_and(|v| v == "application/octet-stream") { + if content_type.is_none_or(|v| v != "application/octet-stream") { bail!( "unexpected content type: {:?}, body: {:?}", content_type, diff --git a/crates/bili_sync/src/config/global.rs b/crates/bili_sync/src/config/global.rs index d4de207..90d9fab 100644 --- a/crates/bili_sync/src/config/global.rs +++ b/crates/bili_sync/src/config/global.rs @@ -13,7 +13,7 @@ pub static CONFIG: Lazy = Lazy::new(|| { let config = Config::load().unwrap_or_else(|err| { if err .downcast_ref::() - .map_or(true, |e| e.kind() != std::io::ErrorKind::NotFound) + .is_none_or(|e| e.kind() != std::io::ErrorKind::NotFound) { panic!("加载配置文件失败,错误为: {err}"); } diff --git a/crates/bili_sync/src/utils/nfo.rs b/crates/bili_sync/src/utils/nfo.rs index 8b4e03e..6b2bc63 100644 --- a/crates/bili_sync/src/utils/nfo.rs +++ b/crates/bili_sync/src/utils/nfo.rs @@ -24,7 +24,7 @@ pub struct NFOSerializer<'a>(pub ModelWrapper<'a>, pub NFOMode); /// serde xml 似乎不太好用,先这么裸着写 /// (真是又臭又长啊 -impl<'a> NFOSerializer<'a> { +impl NFOSerializer<'_> { pub async fn generate_nfo(self, nfo_time_type: &NFOTimeType) -> Result { let mut buffer = r#" "#