summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-20 21:54:29 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-20 21:57:49 +0800
commit9a60751a901f568bdeb154c4115235d4f3a0f8b9 (patch)
tree65df323f6478bae51473a3d6471df39a596ce9c5 /build.rs
parenta9e5c086584d3e697188be7003f564e7e2137135 (diff)
Apply clippy suggestions and improve code quality
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs18
1 files changed, 8 insertions, 10 deletions
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<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()