Struct rustc_ast_pretty::pp::Printer
source · 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
impl Printer
pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W)
pub fn popen(&mut self)
pub fn pclose(&mut self)
pub fn hardbreak_if_not_bol(&mut self)
pub fn space_if_not_bol(&mut self)
pub fn nbsp(&mut self)
pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S)
sourcepub fn synth_comment(&mut self, text: impl Into<Cow<'static, str>>)
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
impl Printer
pub fn visual_align(&mut self)
pub fn break_offset(&mut self, n: usize, off: isize)
pub fn end(&mut self)
pub fn eof(self) -> String
pub fn word<S: Into<Cow<'static, str>>>(&mut self, wrd: S)
fn spaces(&mut self, n: usize)
pub fn zerobreak(&mut self)
pub fn space(&mut self)
pub fn hardbreak(&mut self)
pub fn is_beginning_of_line(&self) -> bool
pub(crate) fn hardbreak_tok_offset(off: isize) -> Token
pub fn trailing_comma(&mut self)
pub fn trailing_comma_or_space(&mut self)
source§impl Printer
impl Printer
pub fn new() -> Self
pub(crate) fn last_token(&self) -> Option<&Token>
pub(crate) fn last_token_still_buffered(&self) -> Option<&Token>
sourcepub(crate) fn replace_last_token_still_buffered(&mut self, token: Token)
pub(crate) fn replace_last_token_still_buffered(&mut self, token: Token)
Be very careful with this!
fn scan_eof(&mut self)
fn scan_begin(&mut self, token: BeginToken)
fn scan_end(&mut self)
fn scan_break(&mut self, token: BreakToken)
fn scan_string(&mut self, string: Cow<'static, str>)
pub(crate) fn offset(&mut self, offset: isize)
fn check_stream(&mut self)
fn advance_left(&mut self)
fn check_stack(&mut self, depth: usize)
fn get_top(&self) -> PrintFrame
fn print_begin(&mut self, token: BeginToken, size: isize)
fn print_end(&mut self)
fn print_break(&mut self, token: BreakToken, size: isize)
fn print_string(&mut self, string: &str)
Auto Trait Implementations§
impl !DynSend for Printer
impl !DynSync for Printer
impl Freeze for Printer
impl RefUnwindSafe for Printer
impl Send for Printer
impl Sync for Printer
impl Unpin for Printer
impl UnwindSafe for Printer
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
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