pub struct FmtCtx<'a> {
pub translated: Option<&'a TranslatedCrate>,
pub generics: BindingStack<Cow<'a, GenericParams>>,
pub locals: Option<&'a Locals>,
pub indent_level: usize,
}
Expand description
Context for formatting.
Fields§
§translated: Option<&'a TranslatedCrate>
§generics: BindingStack<Cow<'a, GenericParams>>
Generics form a stack, where each binder introduces a new level. For DeBruijn indices to work, we keep the innermost parameters at the start of the vector.
locals: Option<&'a Locals>
§indent_level: usize
Implementations§
Source§impl<'a> FmtCtx<'a>
impl<'a> FmtCtx<'a>
pub fn new() -> Self
pub fn get_item( &self, id: AnyTransId, ) -> Result<AnyTransItem<'_>, Option<&Name>>
Sourcepub fn format_decl_id(&self, id: impl Into<AnyTransId>) -> String
pub fn format_decl_id(&self, id: impl Into<AnyTransId>) -> String
Print the whole definition.
fn reborrow<'b>(&'b self) -> FmtCtx<'b>
Trait Implementations§
Source§impl<'c> AstFormatter for FmtCtx<'c>
impl<'c> AstFormatter for FmtCtx<'c>
type Reborrow<'a> = FmtCtx<'a> where Self: 'a
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>,
) -> Resultwhere
GenericParams: HasVectorOf<Id, Output = T>,
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
Auto Trait Implementations§
impl<'a> Freeze for FmtCtx<'a>
impl<'a> RefUnwindSafe for FmtCtx<'a>
impl<'a> Send for FmtCtx<'a>
impl<'a> Sync for FmtCtx<'a>
impl<'a> Unpin for FmtCtx<'a>
impl<'a> UnwindSafe for FmtCtx<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more