Board: formatting code improvement

This commit is contained in:
Simon Gardling 2025-03-20 02:13:02 -04:00
parent 8b50273b43
commit 9ab583a57e
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -120,16 +120,12 @@ impl fmt::Display for Board {
}
// put a line at the bottom of the board too
writeln!(f, " {}", HORIZ_SEP_LINE)?;
writeln!(f, "{}{}", SPACE_PADDING, HORIZ_SEP_LINE)?;
// Print the current score
write!(
f,
"{}",
[Piece::White, Piece::Black]
.map(|p| format!("{} Score: {}\n", p.text(), self.count(p)))
.concat()
)?;
for p in [Piece::White, Piece::Black] {
writeln!(f, "{} Score: {}", p.text(), self.count(p))?;
}
Ok(())
}