1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::ops::Not;
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Debug)]
pub enum Color {
White,
Black,
}
pub const NUM_COLORS: usize = 2;
pub const ALL_COLORS: [Color; NUM_COLORS] = [Color::White, Color::Black];
impl Color {
#[inline]
pub fn to_index(&self) -> usize {
*self as usize
}
}
impl Not for Color {
type Output = Self;
#[inline]
fn not(self) -> Self {
match self {
Color::White => Color::Black,
Color::Black => Color::White,
}
}
}