w_chess/
piece.rs

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
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Piece {
    PAWN = 0,
    BISHOP = 1,
    KNIGHT = 2,
    ROOK = 3,
    QUEEN = 4,
    KING = 5,
    UNKNOWN = 6,
}

impl std::fmt::Display for Piece {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let symbol = match self {
            Piece::PAWN => "Pawn",
            Piece::BISHOP => "Bishop",
            Piece::KNIGHT => "Knight",
            Piece::ROOK => "Rook",
            Piece::QUEEN => "Queen",
            Piece::KING => "King",
            Piece::UNKNOWN => "?",
        };
        write!(f, "{}", symbol)
    }
}