[core] Implement Square::file_rank()

Returns a tuple of the square's file and rank.
This commit is contained in:
Eryn Wells 2024-02-05 13:59:44 -08:00
parent a8034c79aa
commit a5e8f33afe

View file

@ -208,6 +208,10 @@ impl Square {
unsafe { Rank::new_unchecked((self as u8) >> 3) }
}
pub fn file_rank(&self) -> (File, Rank) {
(self.file(), self.rank())
}
pub fn neighbor(self, direction: Direction) -> Option<Square> {
let index: u8 = self as u8;
let dir: i8 = direction.to_offset();