[board] Implement Into<BitBoard> on Squares
Returns a BitBoard representing the square.
This commit is contained in:
parent
3b3062108a
commit
e232d3e19b
1 changed files with 7 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue