1#[derive(Copy, Clone, Debug, Eq, PartialEq)]
14#[repr(u8)]
15pub enum Choice {
16 Unknown = 0,
20
21 Left = 1,
23
24 Right = 2,
26
27 Both = 3,
29}
30
31impl std::ops::BitOrAssign<Choice> for Choice {
32 fn bitor_assign(&mut self, other: Self) {
33 *self = match (*self as u8) | (other as u8) {
34 0 => Self::Unknown,
35 1 => Self::Left,
36 2 => Self::Right,
37 3 => Self::Both,
38 _ => unreachable!(),
39 }
40 }
41}
42
43impl std::ops::Not for Choice {
44 type Output = Choice;
45 fn not(self) -> Self {
46 match self {
47 Self::Unknown => Self::Both,
48 Self::Left => Self::Right,
49 Self::Right => Self::Left,
50 Self::Both => Self::Unknown,
51 }
52 }
53}
54
55impl std::ops::BitAndAssign<Choice> for Choice {
56 fn bitand_assign(&mut self, other: Self) {
57 *self = match (*self as u8) | ((!other as u8) & 0b11) {
58 0 => Self::Unknown,
59 1 => Self::Left,
60 2 => Self::Right,
61 3 => Self::Both,
62 _ => unreachable!(),
63 }
64 }
65}