Use ? operator in tests.

This commit is contained in:
Stephen Chung
2020-03-09 21:09:53 +08:00
parent 63482d5a79
commit 5b5fd162be
6 changed files with 51 additions and 28 deletions

View File

@@ -9,13 +9,17 @@ use std::borrow::Cow;
/// # Example
///
/// ```rust
/// # fn main() -> Result<(), rhai::EvalAltResult> {
/// use rhai::{Engine, Scope};
///
/// let mut engine = Engine::new();
/// let mut my_scope = Scope::new();
///
/// assert!(engine.eval_with_scope::<()>(&mut my_scope, "let x = 5;").is_ok());
/// assert_eq!(engine.eval_with_scope::<i64>(&mut my_scope, "x + 1").unwrap(), 6);
/// engine.eval_with_scope::<()>(&mut my_scope, "let x = 5;")?;
///
/// assert_eq!(engine.eval_with_scope::<i64>(&mut my_scope, "x + 1")?, 6);
/// # Ok(())
/// # }
/// ```
///
/// When searching for variables, newly-added variables are found before similarly-named but older variables,