fn check_power_of_two(enum_def: &Enum) -> bool {
        if enum_def.entries.is_empty() {
            return false;
        }

        let power_of_two_count: u32 = enum_def.entries
            .iter()
            .filter(|e| e.value.is_power_of_two())
            .map(|_v| 1)
            .sum();

        // if we have >= 50% of power of two values assume this enum is being used as bitflags
        let percent = power_of_two_count as f32 / enum_def.entries.len() as f32;
        percent > 0.5
    }
///
/// check if an enum only has power of two values in it. This function calculate in percent how
/// many values that happens to be power of two and returns true if it's a above a certain
/// threshold. The reason for this is that some enums also combinations of other values
/// so it's not possible to *only* check for single power of two values.
///
check if an enum only has power of two values in it. This function calculate in percent how
many values that happens to be power of two and returns true if it's a above a certain
threshold. The reason for this is that some enums also combinations of other values
so it's not possible to *only* check for single power of two values.
check if an enum only has power of two values in it . This function calculate in percent how many values that happens to be power of two and returns true if it ' s a above a certain threshold . The reason for this is that some enums also combinations of other values so it ' s not possible to * only * check for single power of two values .
fn check_power_of_two(enum_def: &Enum) -> bool {
        if enum_def.entries.is_empty() {
            return false;
        }
        let power_of_two_count: u32 = enum_def.entries
            .iter()
            .filter(|e| e.value.is_power_of_two())
            .map(|_v| 1)
            .sum();
        // if we have >= 50% of power of two values assume this enum is being used as bitflags
        let percent = power_of_two_count as f32 / enum_def.entries.len() as f32;
        percent > 0.5
    }
fn check_power_of_two ( enum_def : & Enum ) -> bool { if enum_def . entries . is_empty ( ) { return false ; } let power_of_two_count : u32 = enum_def . entries . iter ( ) . filter ( | e | e . value . is_power_of_two ( ) ) . map ( | _v | 1 ) . sum ( ) ; // if we have >= 50% of power of two values assume this enum is being used as bitflags let percent = power_of_two_count as f32 / enum_def . entries . len ( ) as f32 ; percent > 0.5 }
check if an enum only has power of two values in it.
check if an enum only has power of two values in it .
enum_def
&Enum
enum_def
&Enum