ruabmbua / hidapi-rs

Rust bindings for the hidapi C library
MIT License
165 stars 79 forks source link

Simplified conditional compilation #138

Closed sidit77 closed 5 months ago

sidit77 commented 6 months ago

I recently fount out that this crate currently fails to compile on non-windows platforms when the windows-native feature is active. This is caused by a missing target_os = "windows" in one of the #[cfg(...)] attributes.

I refactored the individual #[cfg(...)] attributes to use the cfg_if macro instead to improve readablillity and hopefully prevent such mistakes in the future.

ruabmbua commented 5 months ago

My last concern was, that cfg_if completely breaks IDE support. Apparently its now limited to only being able to index one of multiple cfg_if branches, which should be good enough.