1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::Bit;
use std::ops::Not;

impl Not for Bit {
    type Output = Self;
    fn not(self) -> Self::Output {
        not(&self)
    }
}

impl Not for &Bit {
    type Output = Bit;
    fn not(self) -> Bit {
        not(self)
    }
}

fn not(a: &Bit) -> Bit {
    match a {
        Bit::One => Bit::Zero,
        Bit::Zero => Bit::One
    }
}