From 58e1094b79bcbaa80cf01d76b07b059ecc49e415 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 17 Jan 2022 21:50:36 +0800 Subject: [PATCH] Register `test` functions in repl. --- src/bin/rhai-repl.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/bin/rhai-repl.rs b/src/bin/rhai-repl.rs index ddbdbd92..5e06f511 100644 --- a/src/bin/rhai-repl.rs +++ b/src/bin/rhai-repl.rs @@ -155,6 +155,13 @@ fn main() { engine.set_module_resolver(resolver); } + engine + .register_fn("test", |x: rhai::INT, y: rhai::INT| format!("{} {}", x, y)) + .register_fn("test", |x: &mut rhai::INT, y: rhai::INT, z: &str| { + *x += y; + println!("{} {} {}", x, y, z); + }); + // Make Engine immutable let engine = engine;