Skip to content

Commit a09c1f8

Browse files
committed
Auto merge of #115782 - a1phyr:improve_pad_adapter, r=dtolnay
Improve `PadAdapter::write_char` Split from #108043
2 parents d7229c4 + 814f4f6 commit a09c1f8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/core/src/fmt/builders.rs

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ impl fmt::Write for PadAdapter<'_, '_> {
4040

4141
Ok(())
4242
}
43+
44+
fn write_char(&mut self, c: char) -> fmt::Result {
45+
if self.state.on_newline {
46+
self.buf.write_str(" ")?;
47+
}
48+
self.state.on_newline = c == '\n';
49+
self.buf.write_char(c)
50+
}
4351
}
4452

4553
/// A struct to help with [`fmt::Debug`](Debug) implementations.

0 commit comments

Comments
 (0)