fix(fmt & dep): clippy & hakari

This commit is contained in:
2025-03-27 17:24:01 +08:00
committed by Samuel Dai
parent 9fa472c8c6
commit 3a513b525c
13 changed files with 52 additions and 33 deletions

View File

@ -6,4 +6,5 @@ edition = "2024"
# authors.workspace = true
[dependencies]
serde_json = "1.0"
serde_json = "1.0"
my-workspace-hack = { version = "0.1", path = "../my-workspace-hack" }

View File

@ -104,14 +104,12 @@ pub fn create_cni_network(cid: String, ns: String) -> Result<(String, String), E
};
if let Some(ips) = json.get("ips").and_then(|ips| ips.as_array()) {
if let Some(first_ip) = ips
.get(0)
.first()
.and_then(|ip| ip.get("address"))
.and_then(|addr| addr.as_str())
{
ip = first_ip.to_string();
} else {
}
} else {
}
}
Err(e) => {
@ -142,14 +140,11 @@ pub fn delete_cni_network(ns: &str, cid: &str) {
}
fn dir_exists(dirname: &Path) -> bool {
path_exists(dirname).map_or(false, |info| info.is_dir())
path_exists(dirname).is_some_and(|info| info.is_dir())
}
fn path_exists(path: &Path) -> Option<fs::Metadata> {
match fs::metadata(path) {
Ok(metadata) => Some(metadata),
Err(_) => None,
}
fs::metadata(path).ok()
}
#[allow(unused)]