[bitboard] Implement From<Option<Square>> for BitBoard

Return an empty BitBoard if the input is None.
This commit is contained in:
Eryn Wells 2024-03-01 15:25:33 -08:00
parent d20119dfe3
commit 349d82304d

View file

@ -164,6 +164,12 @@ impl From<File> for BitBoard {
}
}
impl From<Option<Square>> for BitBoard {
fn from(value: Option<Square>) -> Self {
value.map_or(BitBoard::EMPTY, Into::<BitBoard>::into)
}
}
impl From<Rank> for BitBoard {
fn from(value: Rank) -> Self {
library::FILES[*value.as_index() as usize]