pub struct Printer {
    out: String,
    space: isize,
    buf: RingBuffer<BufEntry>,
    left_total: isize,
    right_total: isize,
    scan_stack: VecDeque<usize>,
    print_stack: Vec<PrintFrame>,
    indent: usize,
    pending_indentation: isize,
    last_printed: Option<Token>,
}

Fields§

§out: String§space: isize

Number of spaces left on line

§buf: RingBuffer<BufEntry>

Ring-buffer of tokens and calculated sizes

§left_total: isize

Running size of stream “…left”

§right_total: isize

Running size of stream “…right”

§scan_stack: VecDeque<usize>

Pseudo-stack, really a ring too. Holds the primary-ring-buffers index of the Begin that started the current block, possibly with the most recent Break after that Begin (if there is any) on top of it. Stuff is flushed off the bottom as it becomes irrelevant due to the primary ring-buffer advancing.

§print_stack: Vec<PrintFrame>

Stack of blocks-in-progress being flushed by print

§indent: usize

Level of indentation of current line

§pending_indentation: isize

Buffered indentation to avoid writing trailing whitespace

§last_printed: Option<Token>

The token most recently popped from the left boundary of the ring-buffer for printing

Implementations§

source§

impl Printer

source

pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W)

source

pub fn popen(&mut self)

source

pub fn pclose(&mut self)

source

pub fn hardbreak_if_not_bol(&mut self)

source

pub fn space_if_not_bol(&mut self)

source

pub fn nbsp(&mut self)

source

pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S)

source

pub fn synth_comment(&mut self, text: impl Into<Cow<'static, str>>)

Synthesizes a comment that was not textually present in the original source file.

source§

impl Printer

source

pub fn rbox(&mut self, indent: isize, breaks: Breaks)

“raw box”

source

pub fn ibox(&mut self, indent: isize)

Inconsistent breaking box

source

pub fn cbox(&mut self, indent: isize)

Consistent breaking box

source

pub fn visual_align(&mut self)

source

pub fn break_offset(&mut self, n: usize, off: isize)

source

pub fn end(&mut self)

source

pub fn eof(self) -> String

source

pub fn word<S: Into<Cow<'static, str>>>(&mut self, wrd: S)

source

fn spaces(&mut self, n: usize)

source

pub fn zerobreak(&mut self)

source

pub fn space(&mut self)

source

pub fn hardbreak(&mut self)

source

pub fn is_beginning_of_line(&self) -> bool

source

pub fn hardbreak_tok_offset(off: isize) -> Token

source

pub fn trailing_comma(&mut self)

source

pub fn trailing_comma_or_space(&mut self)

source§

impl Printer

source

pub fn new() -> Self

source

pub fn last_token(&self) -> Option<&Token>

source

pub fn last_token_still_buffered(&self) -> Option<&Token>

source

pub fn replace_last_token_still_buffered(&mut self, token: Token)

Be very careful with this!

source

fn scan_eof(&mut self)

source

fn scan_begin(&mut self, token: BeginToken)

source

fn scan_end(&mut self)

source

fn scan_break(&mut self, token: BreakToken)

source

fn scan_string(&mut self, string: Cow<'static, str>)

source

pub fn offset(&mut self, offset: isize)

source

fn check_stream(&mut self)

source

fn advance_left(&mut self)

source

fn check_stack(&mut self, depth: usize)

source

fn get_top(&self) -> PrintFrame

source

fn print_begin(&mut self, token: BeginToken, size: isize)

source

fn print_end(&mut self)

source

fn print_break(&mut self, token: BreakToken, size: isize)

source

fn print_string(&mut self, string: &str)

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 192 bytes