[−][src]Macro rhai::combine_with_exported_module
combine_with_exported_module!() { /* proc-macro */ }
Macro to combine a plugin module into an existing module.
Functions and variables in the plugin module overrides any existing similarly-named functions and variables in the target module.
This call is intended to be used within the def_package!
macro to define a custom
package based on a plugin module.
All sub-modules, if any, in the plugin module are flattened and their functions/variables registered at the top level because packages require so.
The text string name in the second parameter can be anything and is reserved for future use; it is recommended to be an ID string that uniquely identifies the plugin 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 mut module = Module::new(); combine_with_exported_module!(&mut module, "my_plugin_module_ID", my_plugin_module); engine.load_package(module); assert_eq!(engine.eval::<i64>("foo(bar())")?, 42);