Is there a way to make an optional dependency non-optional if a cargo feature is disabled ?
@gnzlbg cargo features are expected to be additive, not negative
a lot of stuff breaks if they are negative
so that's the problem, say a crate wants to support
no_std, and it adds a
use_std feature enabled by default
when it is disabled, the crate should be
no_std, but for that it would like to use a
no_std dependency that is not needed when
std is available
that is, "if
use_std is not enabled, then add a dependency"
if we need an additive feature to add the
no_std dependency, we might just call that feature
no_std, and we have added a negative feature
teechnically you can do
[target.'cfg(not(use_std))'.dependencies.dep] for example...
third try’s the charm ^)
[target.cfg(not(feature = "use_std"))
.dependencies.dep] should work indeed
Somehow I have a sinking feeling that I’ve recommended a similar thing before but it turned out that cargo has a white/blacklist of supported cfgs and only allows very limited subset of cfgs :D
yep, that doesn't work