pub fn rewrite_morph<'a>(
model: Model,
rule_sets: &Vec<&'a RuleSet<'a>>,
prop_multiple_equally_applicable: bool,
) -> ModelExpand description
Rewrites a Model by applying rule sets using an optimized, tree-morphing rewriter.
This function traverses the expression tree of the model and applies the given rules
to transform it. It operates on the model’s internal structure, replacing the root
expression and updating the symbol table based on the transformations performed by the
morph function.
§Parameters
model: TheModelto be rewritten. It is consumed and a new, transformed version is returned.rule_sets: A vector ofRuleSetreferences containing the rules for transformation. These rules are grouped by priority before being applied.prop_multiple_equally_applicable: A boolean flag to control behavior when multiple rules of the same priority can be applied to the same expression.- If
true, the rewriter will use a selection strategy (select_panic) that panics. - If
false, the rewriter will use a selection strategy (select_first) that simply picks the first applicable rule it encounters.
- If
§Returns
The rewritten Model after all applicable rules have been applied.
§Panics
This function will panic under two conditions:
- If the internal grouping of rules by priority fails (from
get_rules_grouped). - If
prop_multiple_equally_applicableis set totrueand more than one rule of the same priority can be applied to the same expression.