Fix formatting.

This commit is contained in:
Stephen Chung 2021-12-27 11:43:11 +08:00
parent a07faf7dd9
commit e7ca3f41dd
9 changed files with 21 additions and 39 deletions

View File

@ -91,10 +91,11 @@ impl Engine {
/// ///
/// This function is very low level. /// This function is very low level.
/// ///
/// ## Arguments /// # Arguments
/// ///
/// All the arguments are _consumed_, meaning that they're replaced by `()`. /// All the arguments are _consumed_, meaning that they're replaced by `()`.
/// This is to avoid unnecessarily cloning the arguments. /// This is to avoid unnecessarily cloning the arguments.
///
/// Do not use the arguments after this call. If they are needed afterwards, /// Do not use the arguments after this call. If they are needed afterwards,
/// clone them _before_ calling this function. /// 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, [])?; /// let result = engine.call_fn_raw(&mut scope, &ast, true, true, "bar", None, [])?;
/// assert_eq!(result.cast::<i64>(), 21); /// assert_eq!(result.cast::<i64>(), 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() ])?; /// let result = engine.call_fn_raw(&mut scope, &ast, true, true, "action", Some(&mut value), [ 41_i64.into() ])?;
/// // ^^^^^^^^^^^^^^^^ binding the 'this' pointer /// // ^^^^^^^^^^^^^^^^ 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() ])?; /// engine.call_fn_raw(&mut scope, &ast, true, false, "decl", None, [ 42_i64.into() ])?;
/// // ^^^^^ do not rewind scope /// // ^^^^^ do not rewind scope

View File

@ -120,10 +120,11 @@ impl Engine {
/// ///
/// This function is very low level. /// This function is very low level.
/// ///
/// ## Arguments /// # Arguments
/// ///
/// All the arguments are _consumed_, meaning that they're replaced by `()`. /// All the arguments are _consumed_, meaning that they're replaced by `()`.
/// This is to avoid unnecessarily cloning the arguments. /// This is to avoid unnecessarily cloning the arguments.
///
/// Do not use the arguments after this call. If they are needed afterwards, /// Do not use the arguments after this call. If they are needed afterwards,
/// clone them _before_ calling this function. /// clone them _before_ calling this function.
/// ///
@ -220,7 +221,7 @@ impl NativeCallContext<'_> {
/// ///
/// This function is very low level. /// This function is very low level.
/// ///
/// ## Arguments /// # Arguments
/// ///
/// All arguments may be _consumed_, meaning that they may be replaced by `()`. This is to avoid /// All arguments may be _consumed_, meaning that they may be replaced by `()`. This is to avoid
/// unnecessarily cloning the arguments. /// unnecessarily cloning the arguments.
@ -276,10 +277,11 @@ impl FnPtr {
/// ///
/// This function is very low level. /// This function is very low level.
/// ///
/// ## Arguments /// # Arguments
/// ///
/// All the arguments are _consumed_, meaning that they're replaced by `()`. /// All the arguments are _consumed_, meaning that they're replaced by `()`.
/// This is to avoid unnecessarily cloning the arguments. /// This is to avoid unnecessarily cloning the arguments.
///
/// Do not use the arguments after this call. If they are needed afterwards, /// Do not use the arguments after this call. If they are needed afterwards,
/// clone them _before_ calling this function. /// clone them _before_ calling this function.
#[deprecated( #[deprecated(

View File

@ -150,7 +150,7 @@ impl Engine {
/// This function is very low level. It takes a list of [`TypeId`][std::any::TypeId]'s /// This function is very low level. It takes a list of [`TypeId`][std::any::TypeId]'s
/// indicating the actual types of the parameters. /// indicating the actual types of the parameters.
/// ///
/// ## Arguments /// # Arguments
/// ///
/// Arguments are simply passed in as a mutable array of [`&mut Dynamic`][crate::Dynamic]. /// 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. /// The arguments are guaranteed to be of the correct types matching the [`TypeId`][std::any::TypeId]'s.

View File

@ -411,6 +411,5 @@ pub type OnVarCallback =
Box<dyn Fn(&str, usize, &EvalContext) -> RhaiResultOf<Option<Dynamic>> + 'static>; Box<dyn Fn(&str, usize, &EvalContext) -> RhaiResultOf<Option<Dynamic>> + 'static>;
/// A standard callback function for variable access. /// A standard callback function for variable access.
#[cfg(feature = "sync")] #[cfg(feature = "sync")]
pub type OnVarCallback = Box< pub type OnVarCallback =
dyn Fn(&str, usize, &EvalContext) -> RhaiResultOf<Option<Dynamic>> + Send + Sync + 'static, Box<dyn Fn(&str, usize, &EvalContext) -> RhaiResultOf<Option<Dynamic>> + Send + Sync + 'static>;
>;

View File

@ -871,7 +871,7 @@ impl Module {
/// ///
/// This function is very low level. /// This function is very low level.
/// ///
/// ## Arguments /// # Arguments
/// ///
/// A list of [`TypeId`]'s is taken as the argument types. /// A list of [`TypeId`]'s is taken as the argument types.
/// ///

View File

@ -305,11 +305,7 @@ pub mod array_functions {
} }
#[rhai_fn(return_raw, pure)] #[rhai_fn(return_raw, pure)]
pub fn filter( pub fn filter(ctx: NativeCallContext, array: &mut Array, filter: FnPtr) -> RhaiResultOf<Array> {
ctx: NativeCallContext,
array: &mut Array,
filter: FnPtr,
) -> RhaiResultOf<Array> {
if array.is_empty() { if array.is_empty() {
return Ok(array.clone()); return Ok(array.clone());
} }
@ -863,11 +859,7 @@ pub mod array_functions {
Ok(()) Ok(())
} }
#[rhai_fn(return_raw)] #[rhai_fn(return_raw)]
pub fn drain( pub fn drain(ctx: NativeCallContext, array: &mut Array, filter: FnPtr) -> RhaiResultOf<Array> {
ctx: NativeCallContext,
array: &mut Array,
filter: FnPtr,
) -> RhaiResultOf<Array> {
if array.is_empty() { if array.is_empty() {
return Ok(Array::new()); return Ok(Array::new());
} }
@ -957,11 +949,7 @@ pub mod array_functions {
array.drain(start..start + len).collect() array.drain(start..start + len).collect()
} }
#[rhai_fn(return_raw)] #[rhai_fn(return_raw)]
pub fn retain( pub fn retain(ctx: NativeCallContext, array: &mut Array, filter: FnPtr) -> RhaiResultOf<Array> {
ctx: NativeCallContext,
array: &mut Array,
filter: FnPtr,
) -> RhaiResultOf<Array> {
if array.is_empty() { if array.is_empty() {
return Ok(Array::new()); return Ok(Array::new());
} }
@ -1054,11 +1042,7 @@ pub mod array_functions {
drained drained
} }
#[rhai_fn(name = "==", return_raw, pure)] #[rhai_fn(name = "==", return_raw, pure)]
pub fn equals( pub fn equals(ctx: NativeCallContext, array1: &mut Array, array2: Array) -> RhaiResultOf<bool> {
ctx: NativeCallContext,
array1: &mut Array,
array2: Array,
) -> RhaiResultOf<bool> {
if array1.len() != array2.len() { if array1.len() != array2.len() {
return Ok(false); return Ok(false);
} }

View File

@ -110,12 +110,7 @@ pub mod blob_functions {
} }
} }
#[rhai_fn(return_raw)] #[rhai_fn(return_raw)]
pub fn pad( pub fn pad(ctx: NativeCallContext, blob: &mut Blob, len: INT, item: INT) -> RhaiResultOf<()> {
ctx: NativeCallContext,
blob: &mut Blob,
len: INT,
item: INT,
) -> RhaiResultOf<()> {
if len <= 0 { if len <= 0 {
return Ok(()); return Ok(());
} }

View File

@ -1,6 +1,6 @@
//! Module containing error definitions for the evaluation process. //! 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")] #[cfg(feature = "no_std")]
use core_error::Error; use core_error::Error;
#[cfg(not(feature = "no_std"))] #[cfg(not(feature = "no_std"))]

View File

@ -204,10 +204,11 @@ impl FnPtr {
/// ///
/// This function is very low level. /// This function is very low level.
/// ///
/// ## Arguments /// # Arguments
/// ///
/// All the arguments are _consumed_, meaning that they're replaced by `()`. /// All the arguments are _consumed_, meaning that they're replaced by `()`.
/// This is to avoid unnecessarily cloning the arguments. /// This is to avoid unnecessarily cloning the arguments.
///
/// Do not use the arguments after this call. If they are needed afterwards, /// Do not use the arguments after this call. If they are needed afterwards,
/// clone them _before_ calling this function. /// clone them _before_ calling this function.
#[inline] #[inline]