30 lines
538 B
Rust
30 lines
538 B
Rust
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
|
pub enum Piece {
|
|
Black,
|
|
White,
|
|
}
|
|
|
|
impl Piece {
|
|
pub const fn flip(&self) -> Self {
|
|
match self {
|
|
Piece::Black => Piece::White,
|
|
Piece::White => Piece::Black,
|
|
}
|
|
}
|
|
|
|
pub const fn text(&self) -> &'static str {
|
|
match self {
|
|
Piece::White => "■",
|
|
Piece::Black => "□",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::ops::Not for Piece {
|
|
type Output = Piece;
|
|
|
|
fn not(self) -> Self::Output {
|
|
self.flip()
|
|
}
|
|
}
|