From e232d3e19b304fa7be6a91e8e0175a3bc3d166b3 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 5 Jan 2024 18:22:29 -0800 Subject: [PATCH] [board] Implement Into on Squares Returns a BitBoard representing the square. --- board/src/square.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/board/src/square.rs b/board/src/square.rs index 821d5de..e90b736 100644 --- a/board/src/square.rs +++ b/board/src/square.rs @@ -1,5 +1,6 @@ // Eryn Wells +use crate::bitboard::BitBoard; use std::{fmt, str::FromStr}; pub enum Direction { @@ -156,6 +157,12 @@ impl FromStr for Square { } } +impl Into for Square { + fn into(self) -> BitBoard { + BitBoard::new(1 << self.index) + } +} + impl fmt::Display for Square { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}{}", ('a' as u8 + self.file) as char, self.rank + 1)