Trait AstFormatter

Source
pub trait AstFormatter: Sized {
    type Reborrow<'a>: AstFormatter + 'a
       where Self: 'a;

    // Required methods
    fn get_crate(&self) -> Option<&TranslatedCrate>;
    fn set_generics<'a>(
        &'a self,
        generics: &'a GenericParams,
    ) -> Self::Reborrow<'a>;
    fn set_locals<'a>(&'a self, locals: &'a Locals) -> Self::Reborrow<'a>;
    fn push_binder<'a>(
        &'a self,
        new_params: Cow<'a, GenericParams>,
    ) -> Self::Reborrow<'a>;
    fn increase_indent<'a>(&'a self) -> Self::Reborrow<'a>;
    fn indent(&self) -> String;
    fn format_local_id(&self, f: &mut Formatter<'_>, id: LocalId) -> Result;
    fn format_bound_var<Id: Idx + Display, T>(
        &self,
        f: &mut Formatter<'_>,
        var: DeBruijnVar<Id>,
        var_prefix: &str,
        fmt_var: impl Fn(&T) -> Option<String>,
    ) -> Result
       where GenericParams: HasVectorOf<Id, Output = T>;

    // Provided methods
    fn push_bound_regions<'a>(
        &'a self,
        regions: &'a Vector<RegionId, RegionVar>,
    ) -> Self::Reborrow<'a> { ... }
    fn format_enum_variant(
        &self,
        f: &mut Formatter<'_>,
        type_id: TypeDeclId,
        variant_id: VariantId,
    ) -> Result { ... }
    fn format_field_name(
        &self,
        f: &mut Formatter<'_>,
        type_id: TypeDeclId,
        opt_variant_id: Option<VariantId>,
        field_id: FieldId,
    ) -> Result { ... }
}
Expand description

An AstFormatter contains the context required to pretty-print the ast. An ast type can then be pretty-printed using the FmtWithCtx trait.

Required Associated Types§

Source

type Reborrow<'a>: AstFormatter + 'a where Self: 'a

Required Methods§

Source

fn get_crate(&self) -> Option<&TranslatedCrate>

Source

fn set_generics<'a>(&'a self, generics: &'a GenericParams) -> Self::Reborrow<'a>

Source

fn set_locals<'a>(&'a self, locals: &'a Locals) -> Self::Reborrow<'a>

Source

fn push_binder<'a>( &'a self, new_params: Cow<'a, GenericParams>, ) -> Self::Reborrow<'a>

Source

fn increase_indent<'a>(&'a self) -> Self::Reborrow<'a>

Source

fn indent(&self) -> String

Source

fn format_local_id(&self, f: &mut Formatter<'_>, id: LocalId) -> Result

Source

fn format_bound_var<Id: Idx + Display, T>( &self, f: &mut Formatter<'_>, var: DeBruijnVar<Id>, var_prefix: &str, fmt_var: impl Fn(&T) -> Option<String>, ) -> Result
where GenericParams: HasVectorOf<Id, Output = T>,

Provided Methods§

Source

fn push_bound_regions<'a>( &'a self, regions: &'a Vector<RegionId, RegionVar>, ) -> Self::Reborrow<'a>

Source

fn format_enum_variant( &self, f: &mut Formatter<'_>, type_id: TypeDeclId, variant_id: VariantId, ) -> Result

Source

fn format_field_name( &self, f: &mut Formatter<'_>, type_id: TypeDeclId, opt_variant_id: Option<VariantId>, field_id: FieldId, ) -> Result

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'c> AstFormatter for FmtCtx<'c>

Source§

type Reborrow<'a> = FmtCtx<'a> where Self: 'a