pub struct PrettyPrinter { /* private fields */ }Expand description
Pretty printer for surface expressions.
Implementations§
Source§impl PrettyPrinter
impl PrettyPrinter
Sourcepub fn with_config(config: PrettyConfig) -> Self
pub fn with_config(config: PrettyConfig) -> Self
Create a pretty printer with the given configuration.
Sourcepub fn register_notation(
&mut self,
func_name: &str,
symbol: &str,
precedence: u32,
is_infix: bool,
)
pub fn register_notation( &mut self, func_name: &str, symbol: &str, precedence: u32, is_infix: bool, )
Register a notation for notation-aware printing.
Sourcepub fn try_single_line(&mut self, expr: &SurfaceExpr) -> Option<String>
pub fn try_single_line(&mut self, expr: &SurfaceExpr) -> Option<String>
Try to print an expression on a single line. Returns the string
if it fits within max_width from the current column, otherwise None.
Sourcepub fn print_expr_prec(&mut self, expr: &SurfaceExpr, outer_prec: u32) -> Result
pub fn print_expr_prec(&mut self, expr: &SurfaceExpr, outer_prec: u32) -> Result
Print an expression with precedence-aware parenthesization.
If the expression’s own precedence is less than outer_prec,
parentheses are added.
Sourcepub fn print_pattern(&mut self, pat: &Pattern) -> Result
pub fn print_pattern(&mut self, pat: &Pattern) -> Result
Pretty print a pattern.
Sourcepub fn print_match(
&mut self,
scrutinee: &SurfaceExpr,
arms: &[MatchArm],
) -> Result
pub fn print_match( &mut self, scrutinee: &SurfaceExpr, arms: &[MatchArm], ) -> Result
Pretty print a match expression with aligned arms.
Sourcepub fn print_do(&mut self, actions: &[DoAction]) -> Result
pub fn print_do(&mut self, actions: &[DoAction]) -> Result
Pretty print a do block with indented actions.
Sourcepub fn print_inductive(
&mut self,
name: &str,
univ_params: &[String],
params: &[Binder],
ty: &SurfaceExpr,
ctors: &[Constructor],
) -> Result
pub fn print_inductive( &mut self, name: &str, univ_params: &[String], params: &[Binder], ty: &SurfaceExpr, ctors: &[Constructor], ) -> Result
Pretty print an inductive type declaration.
Sourcepub fn print_expr(&mut self, expr: &SurfaceExpr) -> Result
pub fn print_expr(&mut self, expr: &SurfaceExpr) -> Result
Pretty print a surface expression.
Sourcepub fn print_decl(&mut self, decl: &Decl) -> Result
pub fn print_decl(&mut self, decl: &Decl) -> Result
Pretty print a declaration.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PrettyPrinter
impl RefUnwindSafe for PrettyPrinter
impl Send for PrettyPrinter
impl Sync for PrettyPrinter
impl Unpin for PrettyPrinter
impl UnsafeUnpin for PrettyPrinter
impl UnwindSafe for PrettyPrinter
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