fn determine_enum_type(enum_def: &Enum) -> EnumType {
        // if all number is in a single linear sequence. This currently misses if
        // valid "breaks" in sequences
        let sequential = Self::check_sequential(enum_def);
        // if all numbers aren't overlapping
        let overlapping = Self::check_overlapping(enum_def);
        // check if all values are power of two
        let power_of_two = Self::check_power_of_two(enum_def);

        // If enum is sequential and has no overlapping we can use it as a regular enum
        if sequential && !overlapping {
            return EnumType::Regular;
        }

        // if all values are power of two we assume this should be used as bitfield
        // or has overlapping values we
        if power_of_two || overlapping {
            EnumType::Bitflags
        } else {
            EnumType::Regular
        }
    }
///
/// Figures out the type of enum
///
Figures out the type of enum
Figures out the type of enum
fn determine_enum_type(enum_def: &Enum) -> EnumType {
        // if all number is in a single linear sequence. This currently misses if
        // valid "breaks" in sequences
        let sequential = Self::check_sequential(enum_def);
        // if all numbers aren't overlapping
        let overlapping = Self::check_overlapping(enum_def);
        // check if all values are power of two
        let power_of_two = Self::check_power_of_two(enum_def);
        // If enum is sequential and has no overlapping we can use it as a regular enum
        if sequential && !overlapping {
            return EnumType::Regular;
        }
        // if all values are power of two we assume this should be used as bitfield
        // or has overlapping values we
        if power_of_two || overlapping {
            EnumType::Bitflags
        } else {
            EnumType::Regular
        }
    }
fn determine_enum_type ( enum_def : & Enum ) -> EnumType { // if all number is in a single linear sequence. This currently misses if // valid "breaks" in sequences let sequential = Self :: check_sequential ( enum_def ) ; // if all numbers aren't overlapping let overlapping = Self :: check_overlapping ( enum_def ) ; // check if all values are power of two let power_of_two = Self :: check_power_of_two ( enum_def ) ; // If enum is sequential and has no overlapping we can use it as a regular enum if sequential && ! overlapping { return EnumType :: Regular ; } // if all values are power of two we assume this should be used as bitfield // or has overlapping values we if power_of_two || overlapping { EnumType :: Bitflags } else { EnumType :: Regular } }
Figures out the type of enum
Figures out the type of enum
enum_def
&Enum
enum_def
&Enum