Refine docs and tests.

This commit is contained in:
Stephen Chung
2020-07-06 16:20:03 +08:00
parent 3e45d5d9a5
commit 46cdec1280
7 changed files with 10 additions and 10 deletions

View File

@@ -1046,8 +1046,8 @@ impl Engine {
/// let mut scope = Scope::new();
/// scope.push("x", 40_i64);
///
/// assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x = x + 2; x")?, 42);
/// assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x = x + 2; x")?, 44);
/// assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x += 2; x")?, 42);
/// assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x += 2; x")?, 44);
///
/// // The variable in the scope is modified
/// assert_eq!(scope.get_value::<i64>("x").expect("variable x should exist"), 44);
@@ -1160,7 +1160,7 @@ impl Engine {
/// scope.push("x", 40_i64);
///
/// // Compile a script to an AST and store it for later evaluation
/// let ast = engine.compile("x = x + 2; x")?;
/// let ast = engine.compile("x += 2; x")?;
///
/// // Evaluate it
/// assert_eq!(engine.eval_ast_with_scope::<i64>(&mut scope, &ast)?, 42);