Piece: don't take reference to self

This commit is contained in:
Simon Gardling 2025-04-02 10:01:49 -04:00
parent 30476757da
commit f4007c2d42
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 4 additions and 7 deletions

View File

@ -79,10 +79,7 @@ impl fmt::Display for Board {
write!( write!(
f, f,
"{}|", "{}|",
self.get((i, j).into()) self.get((i, j).into()).map(Piece::symbol).unwrap_or(' ')
.as_ref()
.map(Piece::symbol)
.unwrap_or(' ')
)?; )?;
} }
writeln!(f)?; writeln!(f)?;

View File

@ -7,21 +7,21 @@ pub enum Piece {
} }
impl Piece { impl Piece {
pub const fn flip(&self) -> Self { pub const fn flip(self) -> Self {
match self { match self {
Piece::Black => Piece::White, Piece::Black => Piece::White,
Piece::White => Piece::Black, Piece::White => Piece::Black,
} }
} }
pub const fn symbol(&self) -> char { pub const fn symbol(self) -> char {
match self { match self {
Piece::White => '■', Piece::White => '■',
Piece::Black => '□', Piece::Black => '□',
} }
} }
pub const fn text(&self) -> &'static str { pub const fn text(self) -> &'static str {
match self { match self {
Piece::Black => "Black", Piece::Black => "Black",
Piece::White => "White", Piece::White => "White",