From ed568a9395d3ffa720b2912d1cf478360d3af990 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 3 Mar 2021 22:49:29 +0800 Subject: [PATCH] Make RhaiResult internal. --- src/engine.rs | 2 +- src/fn_register.rs | 2 +- src/lib.rs | 2 +- src/plugin.rs | 3 ++- tests/native.rs | 7 +++++-- tests/plugins.rs | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/engine.rs b/src/engine.rs index bca6b01f..8a29067b 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -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, diff --git a/src/fn_register.rs b/src/fn_register.rs index f35a26f6..bba1e46d 100644 --- a/src/fn_register.rs +++ b/src/fn_register.rs @@ -42,7 +42,7 @@ pub trait RegisterFn { 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 { /// Register a custom fallible function with the [`Engine`]. /// diff --git a/src/lib.rs b/src/lib.rs index ae0dc0f9..72a8c881 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,7 +88,7 @@ mod token; mod r#unsafe; mod utils; -pub type RhaiResult = Result>; +type RhaiResult = Result>; /// The system integer type. It is defined as [`i64`]. /// diff --git a/src/plugin.rs b/src/plugin.rs index d5fcac4f..8aa2d8e1 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -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"))] diff --git a/tests/native.rs b/tests/native.rs index ee1506aa..209c4a57 100644 --- a/tests/native.rs +++ b/tests/native.rs @@ -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> { - fn add_double(context: NativeCallContext, args: &mut [&mut Dynamic]) -> RhaiResult { + fn add_double( + context: NativeCallContext, + args: &mut [&mut Dynamic], + ) -> Result> { let x = args[0].as_int().unwrap(); let y = args[1].as_int().unwrap(); Ok(format!("{}_{}", context.fn_name(), x + 2 * y).into()) diff --git a/tests/plugins.rs b/tests/plugins.rs index b4cbc708..e42c4c73 100644 --- a/tests/plugins.rs +++ b/tests/plugins.rs @@ -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> { Ok(array[0].clone()) } }