opis/bit/
or.rs

1use crate::Bit;
2use std::ops::BitOr;
3
4impl BitOr for Bit {
5    type Output = Self;
6    fn bitor(self, b: Self) -> Self::Output {
7        or(&self, &b)
8    }
9}
10
11impl BitOr<&Bit> for Bit {
12    type Output = Self;
13    fn bitor(self, b: &Bit) -> Self::Output {
14        or(&self, b)
15    }
16}
17
18impl BitOr for &Bit {
19    type Output = Bit;
20    fn bitor(self, b: Self) -> Bit {
21        or(self, b)
22    }
23}
24
25impl BitOr<Bit> for &Bit {
26    type Output = Bit;
27    fn bitor(self, b: Bit) -> Bit {
28        or(self, &b)
29    }
30}
31
32fn or(a: &Bit, b: &Bit) -> Bit {
33    if a == &Bit::Zero &&  b == &Bit::Zero {
34        Bit::Zero
35    } else {
36        Bit::One
37    }
38}