Skip to content

Commit 1bcfd88

Browse files
committed
FMT
1 parent b11171a commit 1bcfd88

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

src/lib.rs

+27-18
Original file line numberDiff line numberDiff line change
@@ -356,26 +356,28 @@ fn extract_crate_names(
356356
});
357357

358358
let dep_tables = dep_tables(cargo_toml.as_table()).chain(target_dep_tables(cargo_toml));
359-
let dep_pkgs = dep_tables.map(|t| t.iter()).flatten().filter_map(move |(dep_name, dep_value)| {
360-
let pkg_name = dep_value.get("package").and_then(|i| i.as_str()).unwrap_or(dep_name);
359+
let dep_pkgs =
360+
dep_tables.map(|t| t.iter()).flatten().filter_map(move |(dep_name, dep_value)| {
361+
let pkg_name = dep_value.get("package").and_then(|i| i.as_str()).unwrap_or(dep_name);
361362

362-
// We already handle this via `root_pkg` above.
363-
if package_name.as_ref().map_or(false, |n| *n == pkg_name) {
364-
return None
365-
}
363+
// We already handle this via `root_pkg` above.
364+
if package_name.as_ref().map_or(false, |n| *n == pkg_name) {
365+
return None
366+
}
366367

367-
// Check if this is a workspace dependency.
368-
let workspace = dep_value.get("workspace").and_then(|w| w.as_bool()).unwrap_or_default();
368+
// Check if this is a workspace dependency.
369+
let workspace =
370+
dep_value.get("workspace").and_then(|w| w.as_bool()).unwrap_or_default();
369371

370-
let pkg_name = workspace
371-
.then(|| workspace_dependencies.get(pkg_name).map(|p| p.as_ref()))
372-
.flatten()
373-
.unwrap_or(pkg_name);
372+
let pkg_name = workspace
373+
.then(|| workspace_dependencies.get(pkg_name).map(|p| p.as_ref()))
374+
.flatten()
375+
.unwrap_or(pkg_name);
374376

375-
let cr = FoundCrate::Name(sanitize_crate_name(dep_name));
377+
let cr = FoundCrate::Name(sanitize_crate_name(dep_name));
376378

377-
Some((pkg_name.to_owned(), cr))
378-
});
379+
Some((pkg_name.to_owned(), cr))
380+
});
379381

380382
Ok(root_pkg.into_iter().chain(dep_pkgs).collect())
381383
}
@@ -385,9 +387,16 @@ fn extract_package_name(cargo_toml: &DocumentMut) -> Option<&str> {
385387
}
386388

387389
fn target_dep_tables(cargo_toml: &DocumentMut) -> impl Iterator<Item = &dyn TableLike> {
388-
cargo_toml.get("target").into_iter().filter_map(Item::as_table_like).flat_map(|t| {
389-
t.iter().map(|(_, value)| value).filter_map(Item::as_table_like).flat_map(dep_tables)
390-
})
390+
cargo_toml
391+
.get("target")
392+
.into_iter()
393+
.filter_map(Item::as_table_like)
394+
.flat_map(|t| {
395+
t.iter()
396+
.map(|(_, value)| value)
397+
.filter_map(Item::as_table_like)
398+
.flat_map(dep_tables)
399+
})
391400
}
392401

393402
fn dep_tables(table: &dyn TableLike) -> impl Iterator<Item = &dyn TableLike> {

0 commit comments

Comments
 (0)