From: Ian Jackson Date: Sat, 29 Oct 2022 21:43:08 +0000 (+0100) Subject: VerticesPrint X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=1249066e6fb4ce21d5c6c7f52b39c8ad50f075c2;p=z3-treefoil VerticesPrint Signed-off-by: Ian Jackson --- diff --git a/src/lib.rs b/src/lib.rs index 06566d8..7fbc602 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,16 +90,23 @@ pub fn shape_all_rotations(shape: &Shape) }) } -pub fn print_shape(shape: &Shape) -> io::Result<()> { - let mut o = io::stdout().lock(); - for vx in shape { - for c in vx { - write!(o, "{}", c)?; +pub struct VerticesPrint<'s>(pub &'s Shape); + +impl Display for VerticesPrint<'_> { + fn fmt(&self, o: &mut fmt::Formatter) -> fmt::Result { + for vx in self.0 { + for c in vx { + write!(o, "{}", c)?; + } + write!(o, ",")?; } - write!(o, ",")?; + Ok(()) } - write!(o, "\n")?; - Ok(()) +} + +pub fn print_shape(shape: &Shape) -> io::Result<()> { + let mut o = io::stdout().lock(); + writeln!(o, "{}", VerticesPrint(shape)) } pub struct Xyzzy<'s>(pub &'s Shape);