#[derive(Clone, Copy)]
pub struct Choice(pub(super) u8);
impl Choice {
#[inline(always)]
pub fn from_lsb(value: u8) -> Self {
Self(core::hint::black_box(value & 1))
}
#[inline(always)]
pub fn unwrap_u8(self) -> u8 {
self.0
}
}
impl core::ops::Not for Choice {
type Output = Self;
fn not(self) -> Self {
Self(self.0 ^ 1)
}
}
impl core::ops::BitAnd for Choice {
type Output = Self;
fn bitand(self, rhs: Self) -> Self {
Self(self.0 & rhs.0)
}
}
impl core::ops::BitOr for Choice {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl core::ops::BitXor for Choice {
type Output = Self;
fn bitxor(self, rhs: Self) -> Self {
Self(self.0 ^ rhs.0)
}
}