pub trait PopcntExt {
// Required method
fn popcnt(&self) -> u64;
}Expand description
Adds a popcnt method to slices of the built-in integer
types, counting their bits without a manual byte cast. Implemented for slices,
arrays and Vecs of u8/u16/u32/u64/u128/usize and their signed
counterparts; bring it into scope with use simd_popcnt::PopcntExt;.
use simd_popcnt::PopcntExt;
let words: &[u64] = &[u64::MAX, 0x0F0F_0F0F_0F0F_0F0F];
assert_eq!(words.popcnt(), 64 + 32);
assert_eq!(vec![1u32, 2, 3].popcnt(), 4);Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".