Piece: don't take reference to self
This commit is contained in:
parent
30476757da
commit
f4007c2d42
@ -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)?;
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user