From a5e8f33afeb054ea6e72bf19f6f3656266c074d8 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Mon, 5 Feb 2024 13:59:44 -0800 Subject: [PATCH] [core] Implement Square::file_rank() Returns a tuple of the square's file and rank. --- core/src/coordinates.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/coordinates.rs b/core/src/coordinates.rs index f40ccb1..68ff3fe 100644 --- a/core/src/coordinates.rs +++ b/core/src/coordinates.rs @@ -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 { let index: u8 = self as u8; let dir: i8 = direction.to_offset();