Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
})
}
-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);