pub trait Pass {
// Required methods
fn visit_expression(
&mut self,
expression: &mut Loc<Expression>,
) -> Result<()>;
fn visit_unit(&mut self, unit: &mut Unit) -> Result<()>;
// Provided method
fn visit_statement(
&mut self,
_statement: &Loc<Statement>,
) -> Result<Option<Vec<Loc<Statement>>>> { ... }
}
Required Methods§
fn visit_expression(&mut self, expression: &mut Loc<Expression>) -> Result<()>
Sourcefn visit_unit(&mut self, unit: &mut Unit) -> Result<()>
fn visit_unit(&mut self, unit: &mut Unit) -> Result<()>
Perform transformations on the unit. This should not transform the body of the unit, that
is handled by visit_expression
Provided Methods§
Sourcefn visit_statement(
&mut self,
_statement: &Loc<Statement>,
) -> Result<Option<Vec<Loc<Statement>>>>
fn visit_statement( &mut self, _statement: &Loc<Statement>, ) -> Result<Option<Vec<Loc<Statement>>>>
Visit a statement, transforming it into a list of new statements which replace it. If the statement should be replaced Ok(Some(new…)) should be returned, if it should be kept, Ok(None) should be returned