[board] Add a Not impl for BitBoard

This trait implements bitwise NOT
This commit is contained in:
Eryn Wells 2023-12-23 09:16:32 -07:00
parent 42d231435e
commit 0838f4fd01

View file

@ -2,7 +2,7 @@
use crate::square::Square;
use std::arch::asm;
use std::ops::{BitAnd, BitOr};
use std::ops::{BitAnd, BitOr, Not};
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BitBoard(u64);
@ -63,9 +63,28 @@ impl BitAnd<&BitBoard> for BitBoard {
}
}
impl Not for BitBoard {
type Output = BitBoard;
#[inline]
fn not(self) -> Self::Output {
BitBoard(!self.0)
}
}
impl Not for &BitBoard {
type Output = BitBoard;
#[inline]
fn not(self) -> Self::Output {
BitBoard(!self.0)
}
}
impl BitOr for BitBoard {
type Output = BitBoard;
#[inline]
fn bitor(self, rhs: Self) -> Self {
BitBoard(self.0 | rhs.0)
}