track current column position when writing
Dependencies
- [2]
ONRIF4V7add basic snapshot test for pretty printer - [3]
QRIJE4AQadd a simple pretty printer for beancount directives - [*]
I2P2FTLEadd basic parser for german decimals - [*]
YDK6X6PPadd a library of important types for beancount
Change contents
- edit in common/beancount-pretty-printer/src/lib.rs at line 7
use bstr::ByteSlice as _; - replacement in common/beancount-pretty-printer/src/lib.rs at line 21
inner: W,inner: TrackingWriter<W>, - edit in common/beancount-pretty-printer/src/lib.rs at line 30
let inner = TrackingWriter::new(inner); - edit in common/beancount-pretty-printer/src/lib.rs at line 180
}struct TrackingWriter<W> {column: usize,inner: W, - edit in common/beancount-pretty-printer/src/lib.rs at line 187[3.5023]
impl<W> TrackingWriter<W>whereW: Write,{fn new(inner: W) -> Self {Self { column: 0, inner }}}impl<W> Write for TrackingWriter<W>whereW: Write,{fn write(&mut self, buf: &[u8]) -> Result<usize> {let written = self.inner.write(buf)?;let buffer = &buf[..written];// Extract the last line written to the inner writerlet line = buffer.rsplit_once_str(b"\n").map_or(buffer, |(_, line)| {// Since we encountered a line separator, reset the columnself.column = 0;line});self.column += line.graphemes().count();Ok(written)}fn flush(&mut self) -> Result<()> {self.inner.flush()}} - replacement in common/beancount-pretty-printer/Cargo.toml at line 9
rust_decimal.workspace = true# Workspace dependenciesbeancount-types.path = "../beancount-types" - replacement in common/beancount-pretty-printer/Cargo.toml at line 12
[dependencies.beancount-types]path = "../beancount-types"# Inherited dependenciesbstr.workspace = truerust_decimal.workspace = true - edit in Cargo.toml at line 10
bstr = "1.0.1" - edit in Cargo.lock at line 61
"bstr", - edit in Cargo.lock at line 123[6.27381][6.27381]
name = "bstr"version = "1.0.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "fca0852af221f458706eb0725c03e4ed6c46af9ac98e6a689d5e634215d594dd"dependencies = ["memchr","once_cell","regex-automata","serde",][[package]] - edit in Cargo.lock at line 701[6.34740][6.34740]
name = "regex-automata"version = "0.1.10"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"[[package]]