diff options
| author | Benoît du Garreau <bdgdlm@outlook.com> | 2023-05-16 17:10:25 +0200 |
|---|---|---|
| committer | Benoît du Garreau <bdgdlm@outlook.com> | 2023-09-12 15:57:36 +0200 |
| commit | 814f4f6f526b302bda9a464130b97502e39cc490 (patch) | |
| tree | ca5e2595d34a8099787477ba82890d5b80a125ac | |
| parent | 5f6ee65f594f59f64c7957dcad90edc0b8830284 (diff) | |
Improve `PadAdapter::write_char`
| -rw-r--r-- | library/core/src/fmt/builders.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/library/core/src/fmt/builders.rs b/library/core/src/fmt/builders.rs index d2c9f980042..9227248041e 100644 --- a/library/core/src/fmt/builders.rs +++ b/library/core/src/fmt/builders.rs @@ -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. |
