Auto merge of #115782 - a1phyr:improve_pad_adapter, r=dtolnay

Improve `PadAdapter::write_char`

Split from #108043
This commit is contained in:
bors 2023-09-17 01:47:49 +00:00
commit a09c1f85f1

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.