[board] Implement Into<BitBoard> on Squares

Returns a BitBoard representing the square.
This commit is contained in:
Eryn Wells 2024-01-05 18:22:29 -08:00
parent 3b3062108a
commit e232d3e19b

View file

@ -1,5 +1,6 @@
// Eryn Wells <eryn@erynwells.me>
use crate::bitboard::BitBoard;
use std::{fmt, str::FromStr};
pub enum Direction {
@ -156,6 +157,12 @@ impl FromStr for Square {
}
}
impl Into<BitBoard> 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)