use bitmask_enum::bitmask;
#[bitmask(u8)]
#[bitmask_config(vec_debug)]
pub enum AssociatedWhitespaceRules {
EnforceBefore = 0b100,
EnforceAfter = 0b010,
BanAfter = 0b001,
}
impl AssociatedWhitespaceRules {
pub const NONE: AssociatedWhitespaceRules = AssociatedWhitespaceRules::none();
pub(crate) const fn from_bits(bits: u8) -> Self {
Self { bits: bits & 0b111 }
}
pub(crate) const fn to_bits(self) -> u8 {
self.bits
}
}
#[test]
fn size_test() {
assert_eq!(::std::mem::size_of::<AssociatedWhitespaceRules>(), 1);
}
#[test]
fn test_from_bits() {
assert!(
AssociatedWhitespaceRules::from_bits(AssociatedWhitespaceRules::EnforceBefore.bits)
.contains(AssociatedWhitespaceRules::EnforceBefore)
);
assert!(
AssociatedWhitespaceRules::from_bits(AssociatedWhitespaceRules::EnforceAfter.bits)
.contains(AssociatedWhitespaceRules::EnforceAfter)
);
assert!(
AssociatedWhitespaceRules::from_bits(AssociatedWhitespaceRules::BanAfter.bits)
.contains(AssociatedWhitespaceRules::BanAfter)
);
}