Make RhaiResult internal.

This commit is contained in:
Stephen Chung
2021-03-03 22:49:29 +08:00
parent dfc1ea692f
commit ed568a9395
6 changed files with 11 additions and 7 deletions

View File

@@ -1,9 +1,12 @@
use rhai::{Dynamic, Engine, EvalAltResult, NativeCallContext, RhaiResult, INT};
use rhai::{Dynamic, Engine, EvalAltResult, NativeCallContext, INT};
use std::any::TypeId;
#[test]
fn test_native_context() -> Result<(), Box<EvalAltResult>> {
fn add_double(context: NativeCallContext, args: &mut [&mut Dynamic]) -> RhaiResult {
fn add_double(
context: NativeCallContext,
args: &mut [&mut Dynamic],
) -> Result<Dynamic, Box<EvalAltResult>> {
let x = args[0].as_int().unwrap();
let y = args[1].as_int().unwrap();
Ok(format!("{}_{}", context.fn_name(), x + 2 * y).into())

View File

@@ -18,7 +18,7 @@ mod test {
#[rhai_fn(get = "foo", return_raw)]
#[inline(always)]
pub fn foo(array: &mut Array) -> RhaiResult {
pub fn foo(array: &mut Array) -> Result<Dynamic, Box<EvalAltResult>> {
Ok(array[0].clone())
}
}