Macro rhai_codegen::set_exported_fn
source · [−]set_exported_fn!() { /* proc-macro */ }
Expand description
Macro to register a plugin function into a Rhai Module
.
Usage
use rhai::plugin::*;
#[export_fn]
fn my_plugin_function(x: i64) -> i64 {
x * 2
}
let mut engine = Engine::new();
let mut module = Module::new();
set_exported_fn!(module, "func", my_plugin_function);
engine.register_global_module(module.into());
assert_eq!(engine.eval::<i64>("func(21)")?, 42);