From 9a60751a901f568bdeb154c4115235d4f3a0f8b9 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 20 Mar 2026 21:54:29 +0800 Subject: Apply clippy suggestions and improve code quality --- build.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'build.rs') diff --git a/build.rs b/build.rs index 3a1f066..0fc9c7f 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,5 @@ use std::env; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process::Command; const COMPILE_INFO_RS: &str = "./src/data/compile_info.rs"; @@ -58,7 +58,7 @@ fn generate_c_binding() { } /// Generate compile info -fn generate_compile_info(repo_root: &PathBuf) -> Result<(), Box> { +fn generate_compile_info(repo_root: &Path) -> Result<(), Box> { // Read the template code let template_code = std::fs::read_to_string(repo_root.join(COMPILE_INFO_RS_TEMPLATE))?; @@ -135,14 +135,12 @@ fn get_version() -> String { Err(_) => return "unknown".to_string(), }; - if let Some(workspace) = cargo_toml.get("workspace") { - if let Some(package) = workspace.get("package") { - if let Some(version) = package.get("version") { - if let Some(version_str) = version.as_str() { - return version_str.to_string(); - } - } - } + if let Some(workspace) = cargo_toml.get("workspace") + && let Some(package) = workspace.get("package") + && let Some(version) = package.get("version") + && let Some(version_str) = version.as_str() + { + return version_str.to_string(); } "unknown".to_string() -- cgit