mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 21:19:35 +00:00
fix: address clippy warnings in tree.rs
This commit is contained in:
@@ -57,17 +57,15 @@ fn print_deps(
|
|||||||
|
|
||||||
if let Some(path) = &dep_path {
|
if let Some(path) = &dep_path {
|
||||||
let dcr_toml = path.join("dcr.toml");
|
let dcr_toml = path.join("dcr.toml");
|
||||||
if dcr_toml.exists() {
|
if dcr_toml.exists() && let Ok(config) = Config::open(&dcr_toml.to_string_lossy()) {
|
||||||
if let Ok(config) = Config::open(&dcr_toml.to_string_lossy()) {
|
if let Some(v) = config.get("package.version").and_then(|v| v.as_str()) {
|
||||||
if let Some(v) = config.get("package.version").and_then(|v| v.as_str()) {
|
version = format!(" v{}", v);
|
||||||
version = format!(" v{}", v);
|
|
||||||
}
|
|
||||||
sub_deps = config
|
|
||||||
.get("dependencies")
|
|
||||||
.and_then(|v| v.as_table())
|
|
||||||
.cloned();
|
|
||||||
resolved_path = Some(path.clone());
|
|
||||||
}
|
}
|
||||||
|
sub_deps = config
|
||||||
|
.get("dependencies")
|
||||||
|
.and_then(|v| v.as_table())
|
||||||
|
.cloned();
|
||||||
|
resolved_path = Some(path.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,35 +89,26 @@ fn print_deps(
|
|||||||
|
|
||||||
println!("{}{}{}{}", prefix, connector, name, version);
|
println!("{}{}{}{}", prefix, connector, name, version);
|
||||||
|
|
||||||
if let Some(s_deps) = sub_deps {
|
if let Some(s_deps) = sub_deps && !seen.contains(*name) {
|
||||||
if !seen.contains(*name) {
|
seen.insert(name.to_string());
|
||||||
seen.insert(name.to_string());
|
let new_prefix = format!("{}{}", prefix, child_prefix);
|
||||||
let new_prefix = format!("{}{}", prefix, child_prefix);
|
if let Some(path) = resolved_path {
|
||||||
if let Some(path) = resolved_path {
|
print_deps(&s_deps, &path, &new_prefix, seen);
|
||||||
print_deps(&s_deps, &path, &new_prefix, seen);
|
|
||||||
}
|
|
||||||
seen.remove(*name);
|
|
||||||
}
|
}
|
||||||
|
seen.remove(*name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_dep_path(value: &Value, base_path: &Path) -> Option<PathBuf> {
|
fn resolve_dep_path(value: &Value, base_path: &Path) -> Option<PathBuf> {
|
||||||
match value {
|
match value {
|
||||||
Value::String(s) => {
|
Value::String(s) => s
|
||||||
if s.starts_with("path:") {
|
.strip_prefix("path:")
|
||||||
Some(base_path.join(&s[5..]))
|
.map(|stripped| base_path.join(stripped)),
|
||||||
} else {
|
Value::Table(t) => t
|
||||||
None
|
.get("path")
|
||||||
}
|
.and_then(|v| v.as_str())
|
||||||
}
|
.map(|path| base_path.join(path)),
|
||||||
Value::Table(t) => {
|
|
||||||
if let Some(path) = t.get("path").and_then(|v| v.as_str()) {
|
|
||||||
Some(base_path.join(path))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user