Macro rhai_codegen::exported_module
source · [−]exported_module!() { /* proc-macro */ }
Expand description
Macro to generate a Rhai Module
from a plugin module defined via #[export_module]
.
Usage
use rhai::plugin::*;
#[export_module]
mod my_plugin_module {
pub fn foo(x: i64) -> i64 { x * 2 }
pub fn bar() -> i64 { 21 }
}
let mut engine = Engine::new();
let module = exported_module!(my_plugin_module);
engine.register_global_module(module.into());
assert_eq!(engine.eval::<i64>("foo(bar())")?, 42);