rust8 0.2.1

A Chip-8 Emulator Library in Rust
Documentation
use std::ops::BitXor;

#[derive(Debug, Clone, Copy, Default, PartialEq)]
pub enum Pixel {
    On,
    #[default]
    Off,
}

impl BitXor for Pixel {
    type Output = Pixel;

    fn bitxor(self, rhs: Self) -> Self::Output {
        match (self, rhs) {
            (Pixel::On, Pixel::Off) => Pixel::On,
            (Pixel::Off, Pixel::On) => Pixel::On,
            _ => Pixel::Off,
        }
    }
}

impl From<bool> for Pixel {
    fn from(value: bool) -> Self {
        if value {
            Pixel::On
        } else {
            Pixel::Off
        }
    }
}