simplify fmt

This commit is contained in:
Simon Gardling 2025-01-28 13:21:14 -05:00
parent 30088f228a
commit 17e774ae57
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -40,8 +40,9 @@ pub struct Board {
impl fmt::Display for Board {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let horiz_sep_line = "-".repeat(BOARD_SIZE * 2 + 1);
for i in 0..BOARD_SIZE {
writeln!(f, "{}", "-".repeat(BOARD_SIZE * 2 + 1))?;
writeln!(f, "{}", horiz_sep_line)?;
write!(f, "|")?;
for j in 0..BOARD_SIZE {
@ -53,7 +54,10 @@ impl fmt::Display for Board {
}
writeln!(f)?;
}
writeln!(f, "{}", "-".repeat(BOARD_SIZE * 2 + 1))?;
// put a line at the bottom of the board too
writeln!(f, "{}", horiz_sep_line)?;
Ok(())
}
}