AdamNiederer / faster

SIMD for humans
Mozilla Public License 2.0
1.56k stars 51 forks source link

"no-std" feature is not additive and should instead be "std" #41

Closed ExpHP closed 6 years ago

ExpHP commented 6 years ago

The way features work in cargo is that each crate in the dependency graph is built a single time with the union of all requested features from each dependent crate. For this reason, enabling a feature should never remove items or change a function's signature; they must only add items.

As an example of how the current setup can go wrong: Suppose a library depends on faster and enables the no-std feature because it doesn't need std, while another crate enables no features and uses the SIMD iterator impls for Vec. If an application depends on both of them, faster gets compiled with no-std, and the second crate will fail to compile.

The recommendation is to have a std feature that is enabled by default:

[features]
default = ["std"]
std = []

(note: the specific name "std" is recommended by the Rust API Guidelines (see C-FEATURE))