1use binrw::binrw;
2
3#[binrw]
7#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
8#[brw(big)]
9pub struct Bool(
10 #[br(map = |n: u8| n > 0)]
11 #[bw(map = |b| u8::from(*b))]
12 pub bool,
13);
14
15impl std::ops::Not for Bool {
16 type Output = Self;
17
18 fn not(self) -> Self::Output {
19 Self(!self.0)
20 }
21}
22
23impl std::ops::Deref for Bool {
24 type Target = bool;
25
26 fn deref(&self) -> &Self::Target {
27 &self.0
28 }
29}
30
31impl std::convert::From<bool> for Bool {
32 fn from(value: bool) -> Self {
33 Self(value)
34 }
35}
36
37impl std::convert::From<Bool> for bool {
38 fn from(value: Bool) -> Self {
39 value.0
40 }
41}