From 758dead6014b798337246716588c942bcc4450ff Mon Sep 17 00:00:00 2001 From: XiuChengWu <732857315@qq.com> Date: Tue, 31 Mar 2026 23:27:26 +0800 Subject: [PATCH] refactor: clean up unused binding and simplify Mutex patterns - plugin_loader.rs: remove unused _plugin_id binding in discover_plugins - http/mod.rs: simplify config() and player_status() Mutex access patterns --- src/core/plugin_loader.rs | 8 ++++---- src/plugins/http/mod.rs | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/core/plugin_loader.rs b/src/core/plugin_loader.rs index 200c68c..bf09d49 100644 --- a/src/core/plugin_loader.rs +++ b/src/core/plugin_loader.rs @@ -146,11 +146,11 @@ impl PluginLoader { continue; } - // 跳过非插件文件(如 registry.json) - let _plugin_id = match path.file_name().and_then(|n| n.to_str()) { - Some(name) if name != "registry.json" => name.to_string(), + // Skip non-plugin entries (e.g. registry.json) + match path.file_name().and_then(|n| n.to_str()) { + Some(name) if name != "registry.json" => {} _ => continue, - }; + } // 扫描版本子目录 for version_entry in std::fs::read_dir(&path)? { diff --git a/src/plugins/http/mod.rs b/src/plugins/http/mod.rs index d682417..374bee7 100644 --- a/src/plugins/http/mod.rs +++ b/src/plugins/http/mod.rs @@ -100,10 +100,12 @@ impl HttpState { } pub(crate) fn config(&self) -> Arc { - self.config - .lock() - .map(|config| Arc::clone(&config)) - .expect("http config state poisoned") + Arc::clone( + &self + .config + .lock() + .expect("http config state poisoned"), + ) } fn replace_config(&self, config: Arc) { @@ -122,8 +124,8 @@ impl HttpState { pub(crate) fn player_status(&self) -> crate::core::message::PlayerStatusData { self.player_status .lock() - .map(|status| status.clone()) .expect("http player status state poisoned") + .clone() } fn update_player_status(&self, status: crate::core::message::PlayerStatusData) {