From 17e774ae5786c638fb7dad232f99f644caf8486a Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 28 Jan 2025 13:21:14 -0500 Subject: [PATCH] simplify fmt --- src/repr.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/repr.rs b/src/repr.rs index 731fb9e..81e3923 100644 --- a/src/repr.rs +++ b/src/repr.rs @@ -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(()) } }