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!(
|
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)?;
|
||||||
|
|||||||
@ -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",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user