You could do as @kobrien said , or you could take a more civilized approach - cpuid crate .
To do this, add it to your Cargo.toml and then to check for POPCNT do
extern crate cpuid; fn have_popcnt() -> Option<bool> { cpuid::identify().ok().map(|ci| ci.has_feature(cpuid::CpuFeature::POPCNT)) }
The have_popcnt() function will return None if the CPU does not support the CPUID or Some(hp) command, where hp determines the availability of POPCNT.
source share