[][src]Trait syntex_syntax2::print::pprust::PrintState

pub trait PrintState<'a> {
    fn writer(&mut self) -> &mut Printer<'a>;
fn boxes(&mut self) -> &mut Vec<Breaks>;
fn comments(&mut self) -> &mut Option<Vec<Comment>>;
fn cur_cmnt_and_lit(&mut self) -> &mut CurrentCommentAndLiteral;
fn literals(&self) -> &Option<Vec<Literal>>; fn word_space(&mut self, w: &str) -> Result<()> { ... }
fn popen(&mut self) -> Result<()> { ... }
fn pclose(&mut self) -> Result<()> { ... }
fn is_begin(&mut self) -> bool { ... }
fn is_end(&mut self) -> bool { ... }
fn is_bol(&mut self) -> bool { ... }
fn hardbreak_if_not_bol(&mut self) -> Result<()> { ... }
fn rbox(&mut self, u: usize, b: Breaks) -> Result<()> { ... }
fn ibox(&mut self, u: usize) -> Result<()> { ... }
fn end(&mut self) -> Result<()> { ... }
fn commasep<T, F>(&mut self, b: Breaks, elts: &[T], op: F) -> Result<()>
    where
        F: FnMut(&mut Self, &T) -> Result<()>
, { ... }
fn next_lit(&mut self, pos: BytePos) -> Option<Literal> { ... }
fn maybe_print_comment(&mut self, pos: BytePos) -> Result<()> { ... }
fn print_comment(&mut self, cmnt: &Comment) -> Result<()> { ... }
fn next_comment(&mut self) -> Option<Comment> { ... }
fn print_literal(&mut self, lit: &Lit) -> Result<()> { ... }
fn print_string(&mut self, st: &str, style: StrStyle) -> Result<()> { ... }
fn print_inner_attributes(&mut self, attrs: &[Attribute]) -> Result<()> { ... }
fn print_inner_attributes_no_trailing_hardbreak(
        &mut self,
        attrs: &[Attribute]
    ) -> Result<()> { ... }
fn print_outer_attributes(&mut self, attrs: &[Attribute]) -> Result<()> { ... }
fn print_inner_attributes_inline(
        &mut self,
        attrs: &[Attribute]
    ) -> Result<()> { ... }
fn print_outer_attributes_inline(
        &mut self,
        attrs: &[Attribute]
    ) -> Result<()> { ... }
fn print_either_attributes(
        &mut self,
        attrs: &[Attribute],
        kind: AttrStyle,
        is_inline: bool,
        trailing_hardbreak: bool
    ) -> Result<()> { ... }
fn print_attribute(&mut self, attr: &Attribute) -> Result<()> { ... }
fn print_attribute_inline(
        &mut self,
        attr: &Attribute,
        is_inline: bool
    ) -> Result<()> { ... }
fn print_meta_list_item(&mut self, item: &NestedMetaItem) -> Result<()> { ... }
fn print_meta_item(&mut self, item: &MetaItem) -> Result<()> { ... }
fn print_tt(&mut self, tt: TokenTree) -> Result<()> { ... }
fn print_tts(&mut self, tts: TokenStream) -> Result<()> { ... }
fn space_if_not_bol(&mut self) -> Result<()> { ... }
fn nbsp(&mut self) -> Result<()> { ... } }

Required methods

fn writer(&mut self) -> &mut Printer<'a>

fn boxes(&mut self) -> &mut Vec<Breaks>

fn comments(&mut self) -> &mut Option<Vec<Comment>>

fn cur_cmnt_and_lit(&mut self) -> &mut CurrentCommentAndLiteral

fn literals(&self) -> &Option<Vec<Literal>>

Loading content...

Provided methods

fn word_space(&mut self, w: &str) -> Result<()>

fn popen(&mut self) -> Result<()>

fn pclose(&mut self) -> Result<()>

fn is_begin(&mut self) -> bool

fn is_end(&mut self) -> bool

fn is_bol(&mut self) -> bool

fn hardbreak_if_not_bol(&mut self) -> Result<()>

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

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

fn end(&mut self) -> Result<()>

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

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

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

fn print_comment(&mut self, cmnt: &Comment) -> Result<()>

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

fn print_literal(&mut self, lit: &Lit) -> Result<()>

fn print_string(&mut self, st: &str, style: StrStyle) -> Result<()>

fn print_inner_attributes(&mut self, attrs: &[Attribute]) -> Result<()>

fn print_inner_attributes_no_trailing_hardbreak(
    &mut self,
    attrs: &[Attribute]
) -> Result<()>

fn print_outer_attributes(&mut self, attrs: &[Attribute]) -> Result<()>

fn print_inner_attributes_inline(&mut self, attrs: &[Attribute]) -> Result<()>

fn print_outer_attributes_inline(&mut self, attrs: &[Attribute]) -> Result<()>

fn print_either_attributes(
    &mut self,
    attrs: &[Attribute],
    kind: AttrStyle,
    is_inline: bool,
    trailing_hardbreak: bool
) -> Result<()>

fn print_attribute(&mut self, attr: &Attribute) -> Result<()>

fn print_attribute_inline(
    &mut self,
    attr: &Attribute,
    is_inline: bool
) -> Result<()>

fn print_meta_list_item(&mut self, item: &NestedMetaItem) -> Result<()>

fn print_meta_item(&mut self, item: &MetaItem) -> Result<()>

fn print_tt(&mut self, tt: TokenTree) -> Result<()>

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.

fn print_tts(&mut self, tts: TokenStream) -> Result<()>

fn space_if_not_bol(&mut self) -> Result<()>

fn nbsp(&mut self) -> Result<()>

Loading content...

Implementors

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

Loading content...