Cargo: how to enable optional dependency/feature, conditional on multiple of my own features?

i can't seem to find any documentation about this anywhere ... so i'll ask here:

is it possible, in my project's Cargo.toml , to enable a feature or optional dependency conditional on multiple other features? for example, say i have:

2d = [
    # i want this only if `physics` is also enabled!
3d = [
    # i want this only if `physics` is also enabled!
physics = [ "heron" ]

version = "2.0.1"
optional = true
version = "0.6"
optional = true

the problem is that, when specified like this, enabling my 2d or 3d feature without my physics feature, also pulls in heron !

i want 2d to only pull in bevy, but 2d + heron to also pull in heron and enable the additional 2d feature on heron.

i've been digging through cargo documentation and haven't found any solution; help?

Currently it's not possible, however Rust 1.60 that will be released April 7 will allow using heron?/2d for that purpose.

1 Like

Ooh! Lovely!

I am using Nightly Rust, so I guess I could try to use it already!

EDIT: it works!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.