From 0556deb33801b6667d01c0fd213c1ca8e0b44c2e Mon Sep 17 00:00:00 2001 From: Loong Date: Mon, 11 Dec 2023 15:28:11 +0800 Subject: [PATCH] fix: clippy warnings --- maa-cli/src/config/asst.rs | 4 ++-- maa-cli/src/log.rs | 2 +- maa-cli/src/main.rs | 8 +------- maa-cli/src/run/copilot.rs | 6 +++--- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/maa-cli/src/config/asst.rs b/maa-cli/src/config/asst.rs index ec97d4c8..4c80cf64 100644 --- a/maa-cli/src/config/asst.rs +++ b/maa-cli/src/config/asst.rs @@ -276,7 +276,7 @@ impl ResourceConfig { let global_resource_dir = PathBuf::from("global") .join(global_resource) .join("resource"); - let full_paths = global_path(base_dirs, &global_resource_dir); + let full_paths = global_path(base_dirs, global_resource_dir); if full_paths.is_empty() { warning!(format!( "Global resource {} not found", @@ -290,7 +290,7 @@ impl ResourceConfig { let platform_diff_resource_dir = PathBuf::from("platform_diff") .join(platform_diff_resource) .join("resource"); - let full_paths = global_path(base_dirs, &platform_diff_resource_dir); + let full_paths = global_path(base_dirs, platform_diff_resource_dir); if full_paths.is_empty() { warning!(format!( "Platform diff resource {} not found", diff --git a/maa-cli/src/log.rs b/maa-cli/src/log.rs index 0cb6caac..a09a748b 100644 --- a/maa-cli/src/log.rs +++ b/maa-cli/src/log.rs @@ -23,7 +23,7 @@ impl> From for LogLevel { } impl LogLevel { - pub fn to_git_flag(&self) -> &str { + pub fn to_git_flag(self) -> &'static str { match self { Self::Error => "-qq", Self::Warning => "-q", diff --git a/maa-cli/src/main.rs b/maa-cli/src/main.rs index 937ae75a..035b58b3 100644 --- a/maa-cli/src/main.rs +++ b/maa-cli/src/main.rs @@ -214,13 +214,7 @@ fn main() -> Result<()> { let cli = CLI::parse(); if cli.verbose != cli.quiet { - unsafe { - set_level( - (level() as u8 + cli.verbose) - .checked_sub(cli.quiet) - .unwrap_or(0), - ) - }; + unsafe { set_level((level() as u8 + cli.verbose).saturating_sub(cli.quiet)) }; } if cli.batch { diff --git a/maa-cli/src/run/copilot.rs b/maa-cli/src/run/copilot.rs index b3e68eee..9306debf 100644 --- a/maa-cli/src/run/copilot.rs +++ b/maa-cli/src/run/copilot.rs @@ -65,7 +65,7 @@ pub fn copilot(uri: impl AsRef, resource_dirs: &Vec) -> Result { - URL(&'a str), + Code(&'a str), File(&'a Path), } @@ -75,7 +75,7 @@ impl CopilotJson<'_> { if let Some(code_str) = trimed.strip_prefix("maa://") { // just check if it's a number if code_str.parse::().is_ok() { - return Ok(CopilotJson::URL(code_str)); + return Ok(CopilotJson::Code(code_str)); } else { bail!("Invalid code: {}", code_str); } @@ -86,7 +86,7 @@ impl CopilotJson<'_> { pub fn get_json_and_file(&self) -> Result<(JsonValue, PathBuf)> { match self { - CopilotJson::URL(code) => { + CopilotJson::Code(code) => { let json_file = dirs::copilot().ensure()?.join(code).with_extension("json"); if json_file.is_file() {