From 32c562e40589f9bad764751561db0dffaff6d07c Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Tue, 26 Dec 2023 11:13:44 -0700 Subject: [PATCH] [board] Implement Color::other() that swaps the color for the other --- board/src/piece.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/board/src/piece.rs b/board/src/piece.rs index 693e190..0ffb9de 100644 --- a/board/src/piece.rs +++ b/board/src/piece.rs @@ -12,6 +12,13 @@ impl Color { pub fn iter() -> impl Iterator { [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)]