fix: address clippy warnings in tree.rs

This commit is contained in:
peoplemiau1
2026-05-15 12:22:05 +03:00
parent a123f647c8
commit 9a24a80d59

View File

@@ -57,8 +57,7 @@ fn print_deps(
if let Some(path) = &dep_path {
let dcr_toml = path.join("dcr.toml");
if dcr_toml.exists() {
if let Ok(config) = Config::open(&dcr_toml.to_string_lossy()) {
if dcr_toml.exists() && let Ok(config) = Config::open(&dcr_toml.to_string_lossy()) {
if let Some(v) = config.get("package.version").and_then(|v| v.as_str()) {
version = format!(" v{}", v);
}
@@ -69,7 +68,6 @@ fn print_deps(
resolved_path = Some(path.clone());
}
}
}
if version.is_empty() {
version = match value {
@@ -91,8 +89,7 @@ fn print_deps(
println!("{}{}{}{}", prefix, connector, name, version);
if let Some(s_deps) = sub_deps {
if !seen.contains(*name) {
if let Some(s_deps) = sub_deps && !seen.contains(*name) {
seen.insert(name.to_string());
let new_prefix = format!("{}{}", prefix, child_prefix);
if let Some(path) = resolved_path {
@@ -101,25 +98,17 @@ fn print_deps(
seen.remove(*name);
}
}
}
}
fn resolve_dep_path(value: &Value, base_path: &Path) -> Option<PathBuf> {
match value {
Value::String(s) => {
if s.starts_with("path:") {
Some(base_path.join(&s[5..]))
} else {
None
}
}
Value::Table(t) => {
if let Some(path) = t.get("path").and_then(|v| v.as_str()) {
Some(base_path.join(path))
} else {
None
}
}
Value::String(s) => s
.strip_prefix("path:")
.map(|stripped| base_path.join(stripped)),
Value::Table(t) => t
.get("path")
.and_then(|v| v.as_str())
.map(|path| base_path.join(path)),
_ => None,
}
}