[][src]Trait syntax::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(&mut self) -> &mut usize;
fn cur_lit(&mut self) -> Option<&Literal>;
fn bump_lit(&mut self) -> Option<Literal>; fn word_space<S: Into<Cow<'static, str>>>(&mut self, w: S) -> 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_path(&mut self, path: &Path) -> 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<()> { ... }
fn print_dollar_crate(&mut self, ident: Ident) -> 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(&mut self) -> &mut usize

fn cur_lit(&mut self) -> Option<&Literal>

fn bump_lit(&mut self) -> Option<Literal>

Loading content...

Provided methods

fn word_space<S: Into<Cow<'static, str>>>(&mut self, w: S) -> 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_path(&mut self, path: &Path) -> 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<()>

fn print_dollar_crate(&mut self, ident: Ident) -> Result<()>

Loading content...

Implementors

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 print_comment(&mut self, cmnt: &Comment) -> Result<()>[src]

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

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

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

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

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

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

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

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

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

fn print_attribute_path(&mut self, path: &Path) -> Result<()>[src]

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

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

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

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

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

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

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

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

fn print_dollar_crate(&mut self, ident: Ident) -> Result<()>[src]

Loading content...