1use std::ops::{BitAnd, BitOr, BitXor, Not};
2
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9#[repr(transparent)]
10pub struct NeoBoolean(pub bool);
11
12impl NeoBoolean {
13 pub const TRUE: Self = Self(true);
14 pub const FALSE: Self = Self(false);
15
16 pub fn new(value: bool) -> Self {
17 Self(value)
18 }
19
20 pub fn as_bool(self) -> bool {
21 self.0
22 }
23}
24
25impl BitAnd for NeoBoolean {
26 type Output = Self;
27 fn bitand(self, rhs: Self) -> Self::Output {
28 Self(self.0 & rhs.0)
29 }
30}
31
32impl BitOr for NeoBoolean {
33 type Output = Self;
34 fn bitor(self, rhs: Self) -> Self::Output {
35 Self(self.0 | rhs.0)
36 }
37}
38
39impl BitXor for NeoBoolean {
40 type Output = Self;
41 fn bitxor(self, rhs: Self) -> Self::Output {
42 Self(self.0 ^ rhs.0)
43 }
44}
45
46impl Not for NeoBoolean {
47 type Output = Self;
48 fn not(self) -> Self::Output {
49 Self(!self.0)
50 }
51}
52
53impl Default for NeoBoolean {
54 fn default() -> Self {
55 Self::FALSE
56 }
57}