Improve PadAdapter::write_char

This commit is contained in:
Benoît du Garreau 2023-05-16 17:10:25 +02:00
parent 5f6ee65f59
commit 814f4f6f52

View File

@ -40,6 +40,14 @@ impl fmt::Write for PadAdapter<'_, '_> {
Ok(())
}
fn write_char(&mut self, c: char) -> fmt::Result {
if self.state.on_newline {
self.buf.write_str(" ")?;
}
self.state.on_newline = c == '\n';
self.buf.write_char(c)
}
}
/// A struct to help with [`fmt::Debug`](Debug) implementations.