pub(crate) trait PatternLocal {
// Required methods
fn lower_no_initial_binding(
&self,
self_name: ValueName,
ctx: &mut Context<'_>,
) -> Result<StatementList>;
fn lower(
&self,
self_name: ValueName,
self_ty: MirType,
ctx: &mut Context<'_>,
) -> Result<StatementList>;
fn condition(
&self,
value_name: &ValueName,
ctx: &mut Context<'_>,
) -> Result<PatternCondition>;
fn value_name(&self) -> ValueName;
fn is_alias(&self) -> bool;
fn is_refutable(&self, ctx: &Context<'_>) -> Usefulness;
}
Required Methods§
fn lower_no_initial_binding( &self, self_name: ValueName, ctx: &mut Context<'_>, ) -> Result<StatementList>
fn lower( &self, self_name: ValueName, self_ty: MirType, ctx: &mut Context<'_>, ) -> Result<StatementList>
fn condition( &self, value_name: &ValueName, ctx: &mut Context<'_>, ) -> Result<PatternCondition>
fn value_name(&self) -> ValueName
fn is_alias(&self) -> bool
fn is_refutable(&self, ctx: &Context<'_>) -> Usefulness
Implementations on Foreign Types§
Source§impl PatternLocal for Loc<Pattern>
impl PatternLocal for Loc<Pattern>
Source§fn lower_no_initial_binding(
&self,
self_name: ValueName,
ctx: &mut Context<'_>,
) -> Result<StatementList>
fn lower_no_initial_binding( &self, self_name: ValueName, ctx: &mut Context<'_>, ) -> Result<StatementList>
Does the same thing as lower but does not create an alias binding for self_name. Used if this is handled elsewhere
Source§fn lower(
&self,
self_name: ValueName,
self_ty: MirType,
ctx: &mut Context<'_>,
) -> Result<StatementList>
fn lower( &self, self_name: ValueName, self_ty: MirType, ctx: &mut Context<'_>, ) -> Result<StatementList>
Lower a pattern to its individual parts. Requires the Pattern::id
to be
present in the code before this
self_name is the name of the operand which this pattern matches
Source§fn condition(
&self,
value_name: &ValueName,
ctx: &mut Context<'_>,
) -> Result<PatternCondition>
fn condition( &self, value_name: &ValueName, ctx: &mut Context<'_>, ) -> Result<PatternCondition>
Returns MIR code for a condition that must hold for expr
to satisfy
this pattern.
Source§fn value_name(&self) -> ValueName
fn value_name(&self) -> ValueName
Get the name which the whole pattern should be bound. In practice, this will be the pattern ID unless the pattern is just a name, in which case it will be a name
This is done to avoid creating too many unnecessary ExprID variables in the output code to make it more readable
Source§fn is_alias(&self) -> bool
fn is_alias(&self) -> bool
Return true if this pattern is just an alias for another name. If this is not
the case, an alias from its true name to value_name
must be generated
Source§fn is_refutable(&self, ctx: &Context<'_>) -> Usefulness
fn is_refutable(&self, ctx: &Context<'_>) -> Usefulness
Returns an error if the pattern is refutable, i.e. it does not match all possible values it binds to