Take self by value in all BitBoard shift methods

This commit is contained in:
Eryn Wells 2024-01-06 16:22:39 -08:00
parent 5a7e498d5d
commit 657a501cb5

View file

@ -7,58 +7,58 @@ impl BitBoard {
const NOT_H_FILE: u64 = 0x7f7f7f7f7f7f7f7f;
#[inline]
pub fn shift_north(&self, n: u8) -> BitBoard {
pub fn shift_north(self, n: u8) -> BitBoard {
BitBoard(self.0 << (8 * n))
}
#[inline]
pub fn shift_north_one(&self) -> BitBoard {
pub fn shift_north_one(self) -> BitBoard {
BitBoard(self.0 << 8)
}
#[inline]
pub fn shift_north_east_one(&self) -> BitBoard {
pub fn shift_north_east_one(self) -> BitBoard {
BitBoard(self.0 << 9 & BitBoard::NOT_A_FILE)
}
#[inline]
pub fn shift_east(&self, n: u8) -> BitBoard {
pub fn shift_east(self, n: u8) -> BitBoard {
// TODO: Implement a bounds check here.
BitBoard(self.0 << n)
}
#[inline]
pub fn shift_east_one(&self) -> BitBoard {
pub fn shift_east_one(self) -> BitBoard {
BitBoard(self.0 << 1 & BitBoard::NOT_A_FILE)
}
#[inline]
pub fn shift_south_east_one(&self) -> BitBoard {
pub fn shift_south_east_one(self) -> BitBoard {
BitBoard(self.0 >> 7 & BitBoard::NOT_A_FILE)
}
#[inline]
pub fn shift_south(&self, n: u8) -> BitBoard {
pub fn shift_south(self, n: u8) -> BitBoard {
BitBoard(self.0 >> (8 * n))
}
#[inline]
pub fn shift_south_one(&self) -> BitBoard {
pub fn shift_south_one(self) -> BitBoard {
BitBoard(self.0 >> 8)
}
#[inline]
pub fn shift_south_west_one(&self) -> BitBoard {
pub fn shift_south_west_one(self) -> BitBoard {
BitBoard(self.0 >> 9 & BitBoard::NOT_H_FILE)
}
#[inline]
pub fn shift_west_one(&self) -> BitBoard {
pub fn shift_west_one(self) -> BitBoard {
BitBoard(self.0 >> 1 & BitBoard::NOT_H_FILE)
}
#[inline]
pub fn shift_north_west_one(&self) -> BitBoard {
pub fn shift_north_west_one(self) -> BitBoard {
BitBoard(self.0 << 7 & BitBoard::NOT_H_FILE)
}
}