1 use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not}; 2 3 #[derive(Copy, Clone, PartialEq, Debug)] 4 #[repr(transparent)] 5 pub struct Block(pub(super) usize); 6 7 impl Block { 8 #[inline] is_empty(self) -> bool9 pub const fn is_empty(self) -> bool { 10 self.0 == Self::NONE.0 11 } 12 13 #[inline] andnot(self, other: Self) -> Self14 pub fn andnot(self, other: Self) -> Self { 15 Self(!other.0 & self.0) 16 } 17 } 18 19 impl Not for Block { 20 type Output = Block; 21 #[inline] not(self) -> Self::Output22 fn not(self) -> Self::Output { 23 Self(self.0.not()) 24 } 25 } 26 27 impl BitAnd for Block { 28 type Output = Block; 29 #[inline] bitand(self, other: Self) -> Self::Output30 fn bitand(self, other: Self) -> Self::Output { 31 Self(self.0.bitand(other.0)) 32 } 33 } 34 35 impl BitAndAssign for Block { 36 #[inline] bitand_assign(&mut self, other: Self)37 fn bitand_assign(&mut self, other: Self) { 38 self.0.bitand_assign(other.0); 39 } 40 } 41 42 impl BitOr for Block { 43 type Output = Block; 44 #[inline] bitor(self, other: Self) -> Self::Output45 fn bitor(self, other: Self) -> Self::Output { 46 Self(self.0.bitor(other.0)) 47 } 48 } 49 50 impl BitOrAssign for Block { 51 #[inline] bitor_assign(&mut self, other: Self)52 fn bitor_assign(&mut self, other: Self) { 53 self.0.bitor_assign(other.0) 54 } 55 } 56 57 impl BitXor for Block { 58 type Output = Block; 59 #[inline] bitxor(self, other: Self) -> Self::Output60 fn bitxor(self, other: Self) -> Self::Output { 61 Self(self.0.bitxor(other.0)) 62 } 63 } 64 65 impl BitXorAssign for Block { 66 #[inline] bitxor_assign(&mut self, other: Self)67 fn bitxor_assign(&mut self, other: Self) { 68 self.0.bitxor_assign(other.0) 69 } 70 } 71