Closed coreylowman closed 1 year ago
Cargo doesn't support mutually exclusive features, so I don't think it's possible to say only use feature num-traits/libm
when not using feature std_math
.
We could make libm
opt-in, but: https://github.com/rust-random/rand/pull/1100/commits/382e3d4d4640c64f05372d534ccbef9e717de9b5
So, with the given motivation, this is probably a no.
You could use compile_error!() if both features are specified, but I see your point. 👍
I'd prefer we don't resort to compile_error!
for the overlapping case: it makes the diamond inheritance problem unsolvable (a bin depending on two libs each depending on rand_distr
but with different feature flags). This is why Cargo doesn't support mutually exclusive features.
So, unfortunately you'll have to live with an unused dependency in your tree and the resultant increase in compile times (but, if libm
is unused, this shouldn't affect binary size).
Background
What is your motivation? I would like to reduce number of dependency crates I need to compile.
What type of application is this? I'm building a deep learning crate
Feature request
In my library, I have the following dependency for rand_distr:
which uses std::math instead of libm.
However when I use
cargo tree
, I see the following for rand_distr:I would like to not have to use libm if I elect to use std_math.
Perhaps there can be a libm feature that is mutually exclusive with std_math?