Skip to content

Commit

Permalink
Auto merge of #115782 - a1phyr:improve_pad_adapter, r=dtolnay
Browse files Browse the repository at this point in the history
Improve `PadAdapter::write_char`

Split from #108043
  • Loading branch information
bors committed Sep 17, 2023
2 parents d7229c4 + 814f4f6 commit a09c1f8
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 a09c1f8

Please sign in to comment.