From e7ca3f41dda6b3410b62f28ddbff540c4297ddeb Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 27 Dec 2021 11:43:11 +0800 Subject: [PATCH] Fix formatting. --- src/api/call_fn.rs | 7 ++++--- src/api/deprecated.rs | 8 +++++--- src/api/register.rs | 2 +- src/func/native.rs | 5 ++--- src/module/mod.rs | 2 +- src/packages/array_basic.rs | 24 ++++-------------------- src/packages/blob_basic.rs | 7 +------ src/types/error.rs | 2 +- src/types/fn_ptr.rs | 3 ++- 9 files changed, 21 insertions(+), 39 deletions(-) diff --git a/src/api/call_fn.rs b/src/api/call_fn.rs index a78943ed..e9e13989 100644 --- a/src/api/call_fn.rs +++ b/src/api/call_fn.rs @@ -91,10 +91,11 @@ impl Engine { /// /// This function is very low level. /// - /// ## Arguments + /// # Arguments /// /// All the arguments are _consumed_, meaning that they're replaced by `()`. /// This is to avoid unnecessarily cloning the arguments. + /// /// Do not use the arguments after this call. If they are needed afterwards, /// clone them _before_ calling this function. /// @@ -130,10 +131,10 @@ impl Engine { /// let result = engine.call_fn_raw(&mut scope, &ast, true, true, "bar", None, [])?; /// assert_eq!(result.cast::(), 21); /// - /// let mut value: Dynamic = 1_i64.into(); + /// let mut value = 1_i64.into(); /// let result = engine.call_fn_raw(&mut scope, &ast, true, true, "action", Some(&mut value), [ 41_i64.into() ])?; /// // ^^^^^^^^^^^^^^^^ binding the 'this' pointer - /// assert_eq!(value.as_int().expect("value should be INT"), 42); + /// assert_eq!(value.as_int().unwrap(), 42); /// /// engine.call_fn_raw(&mut scope, &ast, true, false, "decl", None, [ 42_i64.into() ])?; /// // ^^^^^ do not rewind scope diff --git a/src/api/deprecated.rs b/src/api/deprecated.rs index 6ef2573b..7320451b 100644 --- a/src/api/deprecated.rs +++ b/src/api/deprecated.rs @@ -120,10 +120,11 @@ impl Engine { /// /// This function is very low level. /// - /// ## Arguments + /// # Arguments /// /// All the arguments are _consumed_, meaning that they're replaced by `()`. /// This is to avoid unnecessarily cloning the arguments. + /// /// Do not use the arguments after this call. If they are needed afterwards, /// clone them _before_ calling this function. /// @@ -220,7 +221,7 @@ impl NativeCallContext<'_> { /// /// This function is very low level. /// - /// ## Arguments + /// # Arguments /// /// All arguments may be _consumed_, meaning that they may be replaced by `()`. This is to avoid /// unnecessarily cloning the arguments. @@ -276,10 +277,11 @@ impl FnPtr { /// /// This function is very low level. /// - /// ## Arguments + /// # Arguments /// /// All the arguments are _consumed_, meaning that they're replaced by `()`. /// This is to avoid unnecessarily cloning the arguments. + /// /// Do not use the arguments after this call. If they are needed afterwards, /// clone them _before_ calling this function. #[deprecated( diff --git a/src/api/register.rs b/src/api/register.rs index 66a85220..157f650e 100644 --- a/src/api/register.rs +++ b/src/api/register.rs @@ -150,7 +150,7 @@ impl Engine { /// This function is very low level. It takes a list of [`TypeId`][std::any::TypeId]'s /// indicating the actual types of the parameters. /// - /// ## Arguments + /// # Arguments /// /// Arguments are simply passed in as a mutable array of [`&mut Dynamic`][crate::Dynamic]. /// The arguments are guaranteed to be of the correct types matching the [`TypeId`][std::any::TypeId]'s. diff --git a/src/func/native.rs b/src/func/native.rs index bbf989bb..5c9bf5e6 100644 --- a/src/func/native.rs +++ b/src/func/native.rs @@ -411,6 +411,5 @@ pub type OnVarCallback = Box RhaiResultOf> + 'static>; /// A standard callback function for variable access. #[cfg(feature = "sync")] -pub type OnVarCallback = Box< - dyn Fn(&str, usize, &EvalContext) -> RhaiResultOf> + Send + Sync + 'static, ->; +pub type OnVarCallback = + Box RhaiResultOf> + Send + Sync + 'static>; diff --git a/src/module/mod.rs b/src/module/mod.rs index e7e9b745..db55124d 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -871,7 +871,7 @@ impl Module { /// /// This function is very low level. /// - /// ## Arguments + /// # Arguments /// /// A list of [`TypeId`]'s is taken as the argument types. /// diff --git a/src/packages/array_basic.rs b/src/packages/array_basic.rs index 3e2903a1..aa728088 100644 --- a/src/packages/array_basic.rs +++ b/src/packages/array_basic.rs @@ -305,11 +305,7 @@ pub mod array_functions { } #[rhai_fn(return_raw, pure)] - pub fn filter( - ctx: NativeCallContext, - array: &mut Array, - filter: FnPtr, - ) -> RhaiResultOf { + pub fn filter(ctx: NativeCallContext, array: &mut Array, filter: FnPtr) -> RhaiResultOf { if array.is_empty() { return Ok(array.clone()); } @@ -863,11 +859,7 @@ pub mod array_functions { Ok(()) } #[rhai_fn(return_raw)] - pub fn drain( - ctx: NativeCallContext, - array: &mut Array, - filter: FnPtr, - ) -> RhaiResultOf { + pub fn drain(ctx: NativeCallContext, array: &mut Array, filter: FnPtr) -> RhaiResultOf { if array.is_empty() { return Ok(Array::new()); } @@ -957,11 +949,7 @@ pub mod array_functions { array.drain(start..start + len).collect() } #[rhai_fn(return_raw)] - pub fn retain( - ctx: NativeCallContext, - array: &mut Array, - filter: FnPtr, - ) -> RhaiResultOf { + pub fn retain(ctx: NativeCallContext, array: &mut Array, filter: FnPtr) -> RhaiResultOf { if array.is_empty() { return Ok(Array::new()); } @@ -1054,11 +1042,7 @@ pub mod array_functions { drained } #[rhai_fn(name = "==", return_raw, pure)] - pub fn equals( - ctx: NativeCallContext, - array1: &mut Array, - array2: Array, - ) -> RhaiResultOf { + pub fn equals(ctx: NativeCallContext, array1: &mut Array, array2: Array) -> RhaiResultOf { if array1.len() != array2.len() { return Ok(false); } diff --git a/src/packages/blob_basic.rs b/src/packages/blob_basic.rs index 342a97fc..1a03eae5 100644 --- a/src/packages/blob_basic.rs +++ b/src/packages/blob_basic.rs @@ -110,12 +110,7 @@ pub mod blob_functions { } } #[rhai_fn(return_raw)] - pub fn pad( - ctx: NativeCallContext, - blob: &mut Blob, - len: INT, - item: INT, - ) -> RhaiResultOf<()> { + pub fn pad(ctx: NativeCallContext, blob: &mut Blob, len: INT, item: INT) -> RhaiResultOf<()> { if len <= 0 { return Ok(()); } diff --git a/src/types/error.rs b/src/types/error.rs index da636525..90e9d834 100644 --- a/src/types/error.rs +++ b/src/types/error.rs @@ -1,6 +1,6 @@ //! Module containing error definitions for the evaluation process. -use crate::{Dynamic, ImmutableString, ParseErrorType, Position, INT, RhaiError}; +use crate::{Dynamic, ImmutableString, ParseErrorType, Position, RhaiError, INT}; #[cfg(feature = "no_std")] use core_error::Error; #[cfg(not(feature = "no_std"))] diff --git a/src/types/fn_ptr.rs b/src/types/fn_ptr.rs index 205c6631..74576de1 100644 --- a/src/types/fn_ptr.rs +++ b/src/types/fn_ptr.rs @@ -204,10 +204,11 @@ impl FnPtr { /// /// This function is very low level. /// - /// ## Arguments + /// # Arguments /// /// All the arguments are _consumed_, meaning that they're replaced by `()`. /// This is to avoid unnecessarily cloning the arguments. + /// /// Do not use the arguments after this call. If they are needed afterwards, /// clone them _before_ calling this function. #[inline]