Make RhaiResult internal.
This commit is contained in:
parent
dfc1ea692f
commit
ed568a9395
@ -934,7 +934,7 @@ impl Engine {
|
||||
}
|
||||
|
||||
/// Search for a module within an imports stack.
|
||||
/// [`Position`] in [`EvalAltResult`] is [`None`][Position::None] and must be set afterwards.
|
||||
/// [`Position`] in [`EvalAltResult`] is [`NONE`][Position::NONE] and must be set afterwards.
|
||||
pub fn search_imports(
|
||||
&self,
|
||||
mods: &Imports,
|
||||
|
@ -42,7 +42,7 @@ pub trait RegisterFn<FN, ARGS, RET> {
|
||||
fn register_fn(&mut self, name: &str, f: FN) -> &mut Self;
|
||||
}
|
||||
|
||||
/// Trait to register fallible custom functions returning [`Result`]`<`[`Dynamic`]`, `[`Box`]`<`[`EvalAltResult`]`>>` with the [`Engine`].
|
||||
/// Trait to register fallible custom functions returning [`Result`]`<`[`Dynamic`]`, `[`Box`]`<`[`EvalAltResult`][crate::EvalAltResult]`>>` with the [`Engine`].
|
||||
pub trait RegisterResultFn<FN, ARGS> {
|
||||
/// Register a custom fallible function with the [`Engine`].
|
||||
///
|
||||
|
@ -88,7 +88,7 @@ mod token;
|
||||
mod r#unsafe;
|
||||
mod utils;
|
||||
|
||||
pub type RhaiResult = Result<Dynamic, stdlib::boxed::Box<EvalAltResult>>;
|
||||
type RhaiResult = Result<Dynamic, stdlib::boxed::Box<EvalAltResult>>;
|
||||
|
||||
/// The system integer type. It is defined as [`i64`].
|
||||
///
|
||||
|
@ -2,9 +2,10 @@
|
||||
|
||||
pub use crate::fn_native::{CallableFunction, FnCallArgs};
|
||||
pub use crate::stdlib::{any::TypeId, boxed::Box, format, mem, string::ToString, vec as new_vec};
|
||||
use crate::RhaiResult;
|
||||
pub use crate::{
|
||||
Dynamic, Engine, EvalAltResult, FnAccess, FnNamespace, ImmutableString, Module,
|
||||
NativeCallContext, Position, RegisterFn, RegisterResultFn, RhaiResult,
|
||||
NativeCallContext, Position, RegisterFn, RegisterResultFn,
|
||||
};
|
||||
|
||||
#[cfg(not(features = "no_module"))]
|
||||
|
@ -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())
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user