[board] Implement Color::other() that swaps the color for the other

This commit is contained in:
Eryn Wells 2023-12-26 11:13:44 -07:00
parent fac98735e3
commit 32c562e405

View file

@ -12,6 +12,13 @@ impl Color {
pub fn iter() -> impl Iterator<Item = Color> {
[Color::White, Color::Black].into_iter()
}
pub fn other(&self) -> Color {
match self {
Color::White => Color::Black,
Color::Black => Color::White,
}
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]