feat: make callback inline

上级 348b4833
......@@ -5,24 +5,23 @@ use crate::grammar::grammar::Grammar;
pub struct RuleFactory {}
fn create_rule(id: i32) -> Box<dyn AbstractRule> {
let rule = BeginEndRule {
rule: Rule {
location: ILocation::new(),
id: id,
name: None,
content_name: None
}
};
Box::from(rule)
}
impl RuleFactory {
pub fn get_compiled_rule_id(desc: IRawRule, helper: &mut Grammar, repository: IRawRepository) -> i32 {
pub fn get_compiled_rule_id(mut desc: IRawRule, helper: &mut Grammar, repository: IRawRepository) -> i32 {
match desc.id {
None => {
helper.register_rule(create_rule);
helper.register_rule(|id| {
desc.id = Some(id);
let rule = BeginEndRule {
rule: Rule {
location: ILocation::new(),
id: id,
name: None,
content_name: None
}
};
Box::from(rule)
});
},
Some(_) => {},
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册