For example I define 2 features without dependencies:
[features]
default = []
py2 = []
py3 = []
Based on selected feature (--features py3
) I want to enable different features for a dependency (cpython
):
[dependencies.cpython]
default-features = false
# features = ["python27-sys"] I want to select this if py2 is enabled
features = ["python3-sys"]
optional = true
Can I do this? Or simply can I select features for a dependency from command line as well?
These features are enabled by passing a command-line flag to Rustdoc, but the flags in question are themselves marked as unstable. To use any of these options, pass -Z unstable-options as well as the flag in question to Rustdoc on the command-line.
Cargo "features" provide a mechanism to express conditional compilation and optional dependencies. A package defines a set of named features in the [features] table of Cargo. toml , and each feature can either be enabled or disabled.
It was discussed here. One can do it with /
.
[features]
default = []
py2 = ["cpython", "cpython/python27-sys"]
py3 = ["cpython", "cpython/python3-sys"]
unstable = []
[dependencies.cpython]
# git = "https://github.com/dgrunwald/rust-cpython.git"
default-features = false
optional = true
I've seen nothing about it in documentation or official pages.
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