pub fn is_flag<T: PrimInt>(x: T) -> bool
Expand description

Returns whether this number only has one bit set.

Examples

extern crate xor_distance_exercise;

use xor_distance_exercise::bitops::is_flag;

// Flag must have exactly one bit set to "1".
assert!(is_flag(0b0010));
assert!(!is_flag(0b0101));