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!(
f,
"{}|",
self.get((i, j).into())
.as_ref()
.map(Piece::symbol)
.unwrap_or(' ')
self.get((i, j).into()).map(Piece::symbol).unwrap_or(' ')
)?;
}
writeln!(f)?;

View File

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