Enable feature for example

(Note: I'm not sure about the category)

Maybe I'm wrong, but it seems it's impossible to specify features for the examples in Cargo.toml. Actually, the only way to enable features for an example is either to specify them in the run command: cargo run --example foo --features my_feature, either to define them as default.

When using an IDE like VSCode, you got errors because the plugin isn't aware about the required features for the example.

I propose to add a features key in the [[example]] section in Cargo.toml:

name = "foo"
features = ["my_feature"]
1 Like

Examples have a required_features key, which allows for a nicer error when not providing the feature (requires feature `x`), but doesn't enable it automatically.

1 Like

It's don't seems to work, I got this warning message:

unused manifest key: example.0.required_features

It has to be required-features with a - instead of _: bevy/Cargo.toml at 7fd781e6703cc229ec5dae46ef9cc96ea6e7e52a · bevyengine/bevy · GitHub

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.