I'm adding parking_lot
to my project and I want my dependencies that can optionally use it to use it as well.
For example, I know that Tokio has a feature flag to enable parking_lot
, but I want to find all my dependencies that have similar feature flags.
Yandros on the Rust Discord server whipped up this combination of cargo metadata
and jq
to list the crates that have an optional dependency on a given package (parking_lot
in this example):
cargo metadata --format-version 1 | jq -c '.packages[] | select(
.dependencies | any(
(.name == "parking_lot")
and
(.optional == true)
)
) | .name'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With