Ensure we're at the start of a line before writing a marker. If we're in the middle of a line, this writes a newline first.
(&mut self)
| 278 | /// |
| 279 | /// If we're in the middle of a line, this writes a newline first. |
| 280 | fn ensure_line_start(&mut self) -> std::io::Result<()> { |
| 281 | if !self.at_line_start { |
| 282 | self.writer.write_all(b"\n")?; |
| 283 | self.bytes_written += 1; |
| 284 | self.line += 1; |
| 285 | self.at_line_start = true; |
| 286 | } |
| 287 | Ok(()) |
| 288 | } |
| 289 | |
| 290 | /// Count newlines in a byte slice. |
| 291 | fn count_newlines(data: &[u8]) -> u32 { |