Skip to content

Commit 7a4dae4

Browse files
committed
fix (ci): 修复代码 clippy 错误
1 parent 722f9d9 commit 7a4dae4

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

src-tauri/src/main.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use plugins::{CodeExecutionRequest, ExecutionResult, LanguageInfo, PluginManager
99
use std::fs;
1010
use std::process::{Command, Stdio};
1111
use std::time::{SystemTime, UNIX_EPOCH};
12-
use tauri::{Manager, State};
12+
use tauri::State;
1313
use tokio::sync::Mutex;
1414
use uuid::Uuid;
1515

@@ -22,7 +22,6 @@ async fn execute_code(
2222
request: CodeExecutionRequest,
2323
history: State<'_, ExecutionHistory>,
2424
plugin_manager: State<'_, PluginManagerState>,
25-
app_handle: tauri::AppHandle,
2625
) -> Result<ExecutionResult, String> {
2726
let manager = plugin_manager.lock().await;
2827
let plugin = manager
@@ -152,10 +151,9 @@ async fn get_info(
152151

153152
if let Ok(version_out) = version_output {
154153
if version_out.status.success() {
155-
// 获取路径信息 - 只处理 Python
156154
let path_result = Command::new(cmd)
157155
.arg("-c")
158-
.arg(&plugin.get_path_command())
156+
.arg(plugin.get_path_command())
159157
.output();
160158

161159
let version = String::from_utf8_lossy(&version_out.stdout)
@@ -166,10 +164,10 @@ async fn get_info(
166164
if path_out.status.success() {
167165
String::from_utf8_lossy(&path_out.stdout).trim().to_string()
168166
} else {
169-
format!("Command found but path unavailable")
167+
"Command found but path unavailable".to_string()
170168
}
171169
} else {
172-
format!("Path detection failed")
170+
"Path detection failed".to_string()
173171
};
174172

175173
return Ok(LanguageInfo {

src-tauri/src/plugins/manager.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{LanguagePlugin, python2::Python2Plugin, python3::Python3Plugin};
1+
use super::{python2::Python2Plugin, python3::Python3Plugin, LanguagePlugin};
22
use std::collections::HashMap;
33

44
pub struct PluginManager {
@@ -15,26 +15,30 @@ impl PluginManager {
1515
Self { plugins }
1616
}
1717

18-
pub fn get_plugin(&self, language: &str) -> Option<&Box<dyn LanguagePlugin>> {
19-
self.plugins.get(language)
18+
pub fn get_plugin(&self, language: &str) -> Option<&dyn LanguagePlugin> {
19+
self.plugins.get(language).map(|plugin| plugin.as_ref())
2020
}
2121

2222
pub fn get_supported_languages(&self) -> Vec<String> {
2323
self.plugins.keys().cloned().collect()
2424
}
2525

26+
#[allow(dead_code)]
2627
pub fn register_plugin(&mut self, language: String, plugin: Box<dyn LanguagePlugin>) {
2728
self.plugins.insert(language, plugin);
2829
}
2930

31+
#[allow(dead_code)]
3032
pub fn unregister_plugin(&mut self, language: &str) -> Option<Box<dyn LanguagePlugin>> {
3133
self.plugins.remove(language)
3234
}
3335

36+
#[allow(dead_code)]
3437
pub fn is_language_supported(&self, language: &str) -> bool {
3538
self.plugins.contains_key(language)
3639
}
3740

41+
#[allow(dead_code)]
3842
pub fn get_plugin_info(&self, language: &str) -> Option<PluginInfo> {
3943
self.get_plugin(language).map(|plugin| PluginInfo {
4044
name: plugin.get_language_name().to_string(),
@@ -47,6 +51,7 @@ impl PluginManager {
4751
})
4852
}
4953

54+
#[allow(dead_code)]
5055
pub fn get_all_plugin_info(&self) -> Vec<PluginInfo> {
5156
self.plugins
5257
.values()

0 commit comments

Comments
 (0)