aboutsummaryrefslogtreecommitdiff
path: root/src/square.rs
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-02-02 20:51:25 +0300
committereug-vs <eugene@eug-vs.xyz>2023-02-02 20:51:53 +0300
commitcae14cd6f19c40be2c30b638a51a02c4da0959ea (patch)
tree5e3cc85e5d779beeaaaa837eefed97835b89dca5 /src/square.rs
parentec05e8bfa3f61b86fb83d939ff6fa3ddbc51ce6d (diff)
downloadchessnost-cae14cd6f19c40be2c30b638a51a02c4da0959ea.tar.gz
refactor: use functions for file and rank
Diffstat (limited to 'src/square.rs')
-rw-r--r--src/square.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/square.rs b/src/square.rs
index 2e47bea..8a268ea 100644
--- a/src/square.rs
+++ b/src/square.rs
@@ -27,11 +27,11 @@ impl Square {
}
/// 0-based rank
pub fn rank(&self) -> u8 {
- *self as u8 / 8
+ *self as u8 >> 3
}
/// 0-based file
pub fn file(&self) -> u8 {
- *self as u8 % 8
+ *self as u8 & 7
}
pub fn nort_one(&self) -> Self {