pub struct Writer { /* private fields */ }Expand description
Accumulates rendered text with an indentation level.
Implementations§
Source§impl Writer
impl Writer
Sourcepub fn spaces4() -> Self
pub fn spaces4() -> Self
A writer indenting by four spaces, which is what Rust, C++ and Java conventionally use and what the previous emitters wrote.
Sourcepub const fn depth(&self) -> usize
pub const fn depth(&self) -> usize
How deep it currently is, so a caller can assert on balance.
Sourcepub fn newline(&mut self)
pub fn newline(&mut self)
End the line.
A line with nothing on it gets no indentation: trailing whitespace on a blank line is what a formatter strips and what a byte-comparison then reports as a difference.
Sourcepub fn finish_line(&mut self)
pub fn finish_line(&mut self)
End the line only if something has been written to it.
For a renderer that does not know whether the previous node left the line open.
Sourcepub fn blank_line(&mut self)
pub fn blank_line(&mut self)
An empty line, unless the output is empty or already ends in one.
Idempotent so that a renderer separating two optional sections does not have to know whether the first was there.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Writer
impl RefUnwindSafe for Writer
impl Send for Writer
impl Sync for Writer
impl Unpin for Writer
impl UnsafeUnpin for Writer
impl UnwindSafe for Writer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more