[][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>>,
    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]

pub fn print_mod(&mut self, _mod: &Mod, attrs: &[Attribute]) -> Result<()>[src]

pub fn print_foreign_mod(
    &mut self,
    nmod: &ForeignMod,
    attrs: &[Attribute]
) -> Result<()>
[src]

pub fn print_opt_lifetime(&mut self, lifetime: &Option<Lifetime>) -> Result<()>[src]

pub fn print_generic_arg(&mut self, generic_arg: &GenericArg) -> Result<()>[src]

pub fn print_type(&mut self, ty: &Ty) -> Result<()>[src]

pub fn print_foreign_item(&mut self, item: &ForeignItem) -> Result<()>[src]

pub fn print_item(&mut self, item: &Item) -> Result<()>[src]

Pretty-print an item

pub fn print_enum_def(
    &mut self,
    enum_definition: &EnumDef,
    generics: &Generics,
    ident: Ident,
    span: Span,
    visibility: &Visibility
) -> Result<()>
[src]

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

pub fn print_visibility(&mut self, vis: &Visibility) -> Result<()>[src]

pub fn print_defaultness(&mut self, defaultness: Defaultness) -> Result<()>[src]

pub fn print_struct(
    &mut self,
    struct_def: &VariantData,
    generics: &Generics,
    ident: Ident,
    span: Span,
    print_finalizer: bool
) -> Result<()>
[src]

pub fn print_variant(&mut self, v: &Variant) -> Result<()>[src]

pub fn print_method_sig(
    &mut self,
    ident: Ident,
    generics: &Generics,
    m: &MethodSig,
    vis: &Visibility
) -> Result<()>
[src]

pub fn print_trait_item(&mut self, ti: &TraitItem) -> Result<()>[src]

pub fn print_impl_item(&mut self, ii: &ImplItem) -> Result<()>[src]

pub fn print_stmt(&mut self, st: &Stmt) -> Result<()>[src]

pub fn print_block(&mut self, blk: &Block) -> Result<()>[src]

pub fn print_block_unclosed(&mut self, blk: &Block) -> Result<()>[src]

pub fn print_block_unclosed_with_attrs(
    &mut self,
    blk: &Block,
    attrs: &[Attribute]
) -> Result<()>
[src]

pub fn print_block_unclosed_indent(
    &mut self,
    blk: &Block,
    indented: usize
) -> Result<()>
[src]

pub fn print_block_with_attrs(
    &mut self,
    blk: &Block,
    attrs: &[Attribute]
) -> Result<()>
[src]

pub fn print_block_maybe_unclosed(
    &mut self,
    blk: &Block,
    indented: usize,
    attrs: &[Attribute],
    close_box: bool
) -> Result<()>
[src]

pub fn print_if(
    &mut self,
    test: &Expr,
    blk: &Block,
    elseopt: Option<&Expr>
) -> Result<()>
[src]

pub fn print_if_let(
    &mut self,
    pats: &[P<Pat>],
    expr: &Expr,
    blk: &Block,
    elseopt: Option<&Expr>
) -> Result<()>
[src]

pub fn print_mac(&mut self, m: &Mac) -> Result<()>[src]

pub fn print_expr_maybe_paren(&mut self, expr: &Expr, prec: i8) -> Result<()>[src]

pub fn print_expr_as_cond(&mut self, expr: &Expr) -> Result<()>[src]

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

pub fn print_expr(&mut self, expr: &Expr) -> Result<()>[src]

pub fn print_local_decl(&mut self, loc: &Local) -> Result<()>[src]

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

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

pub fn print_name(&mut self, name: Name) -> Result<()>[src]

pub fn print_for_decl(&mut self, loc: &Local, coll: &Expr) -> Result<()>[src]

pub fn print_pat(&mut self, pat: &Pat) -> Result<()>[src]

pub fn print_fn(
    &mut self,
    decl: &FnDecl,
    header: FnHeader,
    name: Option<Ident>,
    generics: &Generics,
    vis: &Visibility
) -> Result<()>
[src]

pub fn print_fn_args_and_ret(&mut self, decl: &FnDecl) -> Result<()>[src]

pub fn print_fn_block_args(&mut self, decl: &FnDecl) -> Result<()>[src]

pub fn print_movability(&mut self, movability: Movability) -> Result<()>[src]

pub fn print_asyncness(&mut self, asyncness: IsAsync) -> Result<()>[src]

pub fn print_capture_clause(&mut self, capture_clause: CaptureBy) -> Result<()>[src]

pub fn print_type_bounds(
    &mut self,
    prefix: &'static str,
    bounds: &[GenericBound]
) -> Result<()>
[src]

pub fn print_lifetime(&mut self, lifetime: Lifetime) -> Result<()>[src]

pub fn print_lifetime_bounds(
    &mut self,
    lifetime: Lifetime,
    bounds: &GenericBounds
) -> Result<()>
[src]

pub fn print_generic_params(
    &mut self,
    generic_params: &[GenericParam]
) -> Result<()>
[src]

pub fn print_where_clause(&mut self, where_clause: &WhereClause) -> Result<()>[src]

pub fn print_use_tree(&mut self, tree: &UseTree) -> Result<()>[src]

pub fn print_mutability(&mut self, mutbl: Mutability) -> Result<()>[src]

pub fn print_mt(&mut self, mt: &MutTy) -> Result<()>[src]

pub fn print_arg(&mut self, input: &Arg, is_closure: bool) -> Result<()>[src]

pub fn print_fn_output(&mut self, decl: &FnDecl) -> Result<()>[src]

pub fn print_ty_fn(
    &mut self,
    abi: Abi,
    unsafety: Unsafety,
    decl: &FnDecl,
    name: Option<Ident>,
    generic_params: &[GenericParam]
) -> Result<()>
[src]

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

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

pub fn print_opt_abi_and_extern_if_nondefault(
    &mut self,
    opt_abi: Option<Abi>
) -> Result<()>
[src]

pub fn print_extern_opt_abi(&mut self, opt_abi: Option<Abi>) -> Result<()>[src]

pub fn print_fn_header_info(
    &mut self,
    header: FnHeader,
    vis: &Visibility
) -> Result<()>
[src]

pub fn print_unsafety(&mut self, s: Unsafety) -> Result<()>[src]

pub fn print_is_auto(&mut self, s: IsAuto) -> 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 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]

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 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]

Auto Trait Implementations

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

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

Blanket Implementations

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

impl<T> From<T> for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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

impl<E> SpecializationError for E[src]

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

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

impl<T> Erased for T[src]