开源rust规则引擎,向引擎加入wme的函数如下:
pub fn add_wme(&mut self, wme: Wme) {
let log = self.log.new(o!("wme" => format!("{:?}", wme)));
trace!(log, "add wme");
observe!(
log,
Trace::AddedWme {
id: wme.0[0],
attribute: wme.0[1],
value: wme.0[2],
}
);
//rustfmt是Rust官方出品的统一代码风格组件
//这个是类似000,001,010,011....的次序排列的,01234567
//skip的意思是,不要rustfmt对这段代码做修改,https://github.com/rust-lang/rustfmt,
// “For things you do not want rustfmt to mangle, use #[rustfmt::skip]”
// 根据WME的三个值,生成8种可能的AlphaTest
#[rustfmt::skip]
let tests = [
AlphaTest([None, None, None ]),
AlphaTest([None, None, Some(wme.0[2])]),
AlphaTest([None, Some(wme.0[1]), None ]),
AlphaTest([None, Some(wme.0[1]), Some(wme.0[2])]),
AlphaTest([Some(wme.0[0]), None, None ]),
AlphaTest([Some(wme.0[0]), None, Some(wme.0[2])]),
AlphaTest([Some(wme.0[0]), Some(wme.0[1]), None ]),
AlphaTest([Some(wme.0[0]), Some(wme.0[1]), Som