diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-20 21:54:29 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-20 21:57:49 +0800 |
| commit | 9a60751a901f568bdeb154c4115235d4f3a0f8b9 (patch) | |
| tree | 65df323f6478bae51473a3d6471df39a596ce9c5 /build.rs | |
| parent | a9e5c086584d3e697188be7003f564e7e2137135 (diff) | |
Apply clippy suggestions and improve code quality
Diffstat (limited to 'build.rs')
| -rw-r--r-- | build.rs | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -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<dyn std::error::Error>> { +fn generate_compile_info(repo_root: &Path) -> Result<(), Box<dyn std::error::Error>> { // 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() |
