pub struct MatchCompiler { /* private fields */ }Expand description
Pattern match compiler.
Implementations§
Source§impl MatchCompiler
impl MatchCompiler
Sourcepub fn register_constructors(
&mut self,
ind_name: Name,
ctors: Vec<ConstructorInfo>,
)
pub fn register_constructors( &mut self, ind_name: Name, ctors: Vec<ConstructorInfo>, )
Register constructors for an inductive type.
Sourcepub fn get_constructors(&self, ind_name: &Name) -> Option<&Vec<ConstructorInfo>>
pub fn get_constructors(&self, ind_name: &Name) -> Option<&Vec<ConstructorInfo>>
Get constructors for an inductive type.
Sourcepub fn compile_match(
&mut self,
scrutinees: &[Expr],
arms: &[MatchArm],
) -> Result<CompileResult, String>
pub fn compile_match( &mut self, scrutinees: &[Expr], arms: &[MatchArm], ) -> Result<CompileResult, String>
Compile a match expression.
Takes a list of scrutinees and match arms, produces a decision tree.
Sourcepub fn check_exhaustive(
&self,
patterns: &[Pattern],
ind_name: &Name,
) -> Result<(), String>
pub fn check_exhaustive( &self, patterns: &[Pattern], ind_name: &Name, ) -> Result<(), String>
Check if patterns are exhaustive.
Handles Or-patterns (flattened), As-patterns (inner checked), Var/Wildcard (irrefutable), and constructor coverage.
Sourcepub fn check_redundant(&self, patterns: &[Pattern]) -> Vec<usize>
pub fn check_redundant(&self, patterns: &[Pattern]) -> Vec<usize>
Check if any patterns are redundant.
A pattern is redundant if it is preceded by a wildcard/var, or if a constructor or literal it matches was already covered earlier (including via Or-patterns).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MatchCompiler
impl RefUnwindSafe for MatchCompiler
impl Send for MatchCompiler
impl Sync for MatchCompiler
impl Unpin for MatchCompiler
impl UnsafeUnpin for MatchCompiler
impl UnwindSafe for MatchCompiler
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