[board] Add a Not impl for BitBoard
This trait implements bitwise NOT
This commit is contained in:
parent
42d231435e
commit
0838f4fd01
1 changed files with 20 additions and 1 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::square::Square;
|
use crate::square::Square;
|
||||||
use std::arch::asm;
|
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)]
|
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||||
pub struct BitBoard(u64);
|
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 {
|
impl BitOr for BitBoard {
|
||||||
type Output = BitBoard;
|
type Output = BitBoard;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn bitor(self, rhs: Self) -> Self {
|
fn bitor(self, rhs: Self) -> Self {
|
||||||
BitBoard(self.0 | rhs.0)
|
BitBoard(self.0 | rhs.0)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue