Skip to content

Commit

Permalink
Improve PadAdapter::write_char
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Sep 12, 2023
1 parent 5f6ee65 commit 814f4f6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/core/src/fmt/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 814f4f6

Please sign in to comment.