Attribute Macro rhai_codegen::export_fn

source · []
#[export_fn]
Expand description

Attribute, when put on a Rust function, turns it into a plugin function.

Usage

use rhai::plugin::*;

#[export_fn]
fn my_plugin_function(x: i64) -> i64 {
    x * 2
}

let mut engine = Engine::new();

register_exported_fn!(engine, "func", my_plugin_function);

assert_eq!(engine.eval::<i64>("func(21)")?, 42);