[][src]Struct syntax::print::pprust::State

pub struct State<'a> {
    pub s: Printer<'a>,
    // some fields omitted
}

Fields

s: Printer<'a>

Methods

impl<'a> State<'a>
[src]

pub fn new_from_input(
    cm: &'a SourceMap,
    sess: &ParseSess,
    filename: FileName,
    input: &mut dyn Read,
    out: Box<dyn Write + 'a>,
    ann: &'a dyn PpAnn,
    is_expanded: bool
) -> State<'a>
[src]

pub fn new(
    cm: &'a SourceMap,
    out: Box<dyn Write + 'a>,
    ann: &'a dyn PpAnn,
    comments: Option<Vec<Comment>>,
    literals: Option<Vec<Literal>>,
    is_expanded: bool
) -> State<'a>
[src]

impl<'a> State<'a>
[src]

pub fn cbox(&mut self, u: usize) -> Result<()>
[src]

pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S) -> Result<()>
[src]

pub fn head<S: Into<Cow<'static, str>>>(&mut self, w: S) -> Result<()>
[src]

pub fn bopen(&mut self) -> Result<()>
[src]

pub fn bclose_(&mut self, span: Span, indented: usize) -> Result<()>
[src]

pub fn bclose_maybe_open(
    &mut self,
    span: Span,
    indented: usize,
    close_box: bool
) -> Result<()>
[src]

pub fn bclose(&mut self, span: Span) -> Result<()>
[src]

pub fn in_cbox(&self) -> bool
[src]

pub fn break_offset_if_not_bol(&mut self, n: usize, off: isize) -> Result<()>
[src]

pub fn synth_comment(&mut self, text: String) -> Result<()>
[src]

pub fn commasep_cmnt<T, F, G>(
    &mut self,
    b: Breaks,
    elts: &[T],
    op: F,
    get_span: G
) -> Result<()> where
    F: FnMut(&mut State, &T) -> Result<()>,
    G: FnMut(&T) -> Span
[src]

pub fn commasep_exprs(&mut self, b: Breaks, exprs: &[P<Expr>]) -> Result<()>
[src]

Pretty-print an item

Print an expr using syntax that's acceptable in a condition position, such as the cond in if cond { ... }.

pub fn maybe_print_trailing_comment(
    &mut self,
    span: Span,
    next_pos: Option<BytePos>
) -> Result<()>
[src]

Trait Implementations

impl<'a> PrintState<'a> for State<'a>
[src]

fn word_space<S: Into<Cow<'static, str>>>(&mut self, w: S) -> Result<()>
[src]

fn popen(&mut self) -> Result<()>
[src]

fn pclose(&mut self) -> Result<()>
[src]

fn is_begin(&mut self) -> bool
[src]

fn is_end(&mut self) -> bool
[src]

fn is_bol(&mut self) -> bool
[src]

fn hardbreak_if_not_bol(&mut self) -> Result<()>
[src]

fn rbox(&mut self, u: usize, b: Breaks) -> Result<()>
[src]

fn ibox(&mut self, u: usize) -> Result<()>
[src]

fn end(&mut self) -> Result<()>
[src]

fn commasep<T, F>(&mut self, b: Breaks, elts: &[T], op: F) -> Result<()> where
    F: FnMut(&mut Self, &T) -> Result<()>, 
[src]

fn next_lit(&mut self, pos: BytePos) -> Option<Literal>
[src]

fn maybe_print_comment(&mut self, pos: BytePos) -> Result<()>
[src]

fn next_comment(&mut self) -> Option<Comment>
[src]

This doesn't deserve to be called "pretty" printing, but it should be meaning-preserving. A quick hack that might help would be to look at the spans embedded in the TTs to decide where to put spaces and newlines. But it'd be better to parse these according to the grammar of the appropriate macro, transcribe back into the grammar we just parsed from, and then pretty-print the resulting AST nodes (so, e.g., we print expression arguments as expressions). It can be done! I think. Read more

fn space_if_not_bol(&mut self) -> Result<()>
[src]

fn nbsp(&mut self) -> Result<()>
[src]

Auto Trait Implementations

impl<'a> !Send for State<'a>

impl<'a> !Sync for State<'a>

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<E> SpecializationError for E
[src]

impl<T> Erased for T
[src]

impl<T> Send for T where
    T: ?Sized
[src]

impl<T> Sync for T where
    T: ?Sized
[src]

impl<T> Erased for T