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

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(crate) 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(crate) fn last_token(&self) -> Option<&Token>

source

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

source

pub(crate) 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(crate) 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> Aligned for T

source§

const ALIGN: Alignment = _

Alignment of Self.
source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<'a, T> Captures<'a> for T
where 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