[board] Implement Color::other() that swaps the color for the other
This commit is contained in:
parent
fac98735e3
commit
32c562e405
1 changed files with 7 additions and 0 deletions
|
@ -12,6 +12,13 @@ impl Color {
|
||||||
pub fn iter() -> impl Iterator<Item = Color> {
|
pub fn iter() -> impl Iterator<Item = Color> {
|
||||||
[Color::White, Color::Black].into_iter()
|
[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)]
|
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue