Make API chainable.

This commit is contained in:
Stephen Chung
2020-07-12 11:46:53 +08:00
parent 2a8d63fd5f
commit 8449f8c55e
22 changed files with 223 additions and 143 deletions

View File

@@ -28,11 +28,11 @@ let mut scope = Scope::new();
// Then push (i.e. add) some initialized variables into the state.
// Remember the system number types in Rhai are i64 (i32 if 'only_i32') ond f64.
// Better stick to them or it gets hard working with the script.
scope.push("y", 42_i64);
scope.push("z", 999_i64);
// 'set_value' adds a variable when one doesn't exist
scope.set_value("s", "hello, world!".to_string()); // remember to use 'String', not '&str'
scope
.push("y", 42_i64)
.push("z", 999_i64)
.set_value("s", "hello, world!".to_string()); //'set_value' adds a variable when one doesn't exist
// remember to use 'String', not '&str'
// First invocation
engine.eval_with_scope::<()>(&mut scope, r"