conjure_oxide

Function get_rule_by_name

Source
pub fn get_rule_by_name(name: &str) -> Option<&'static Rule<'static>>
Expand description

Get a rule by name. Returns the rule with the given name or None if it doesn’t exist.

§Example

use conjure_core::rule_engine::register_rule;
use conjure_core::rule_engine::{Rule, ApplicationResult, Reduction, get_rule_by_name};
use conjure_core::ast::Expression;
use conjure_core::model::Model;

#[register_rule]
fn identity(expr: &Expression, mdl: &Model) -> ApplicationResult {
 Ok(Reduction::pure(expr.clone()))
}

fn main() {
println!("Rule: {:?}", get_rule_by_name("identity"));
}

This will print:

Rule: Some(Rule { name: "identity", application: MEM })