Improve docs.
This commit is contained in:
@@ -128,11 +128,11 @@ impl<'a, T: Variant + Clone> TypeBuilder<'a, T> {
|
||||
|
||||
/// Register a custom function.
|
||||
#[inline(always)]
|
||||
pub fn with_fn<N, A, F, R, S>(&mut self, name: N, method: F) -> &mut Self
|
||||
where
|
||||
N: AsRef<str> + Into<Identifier>,
|
||||
F: RegisterNativeFunction<A, R, S>,
|
||||
{
|
||||
pub fn with_fn<A, R, S>(
|
||||
&mut self,
|
||||
name: impl AsRef<str> + Into<Identifier>,
|
||||
method: impl RegisterNativeFunction<A, R, S>,
|
||||
) -> &mut Self {
|
||||
self.engine.register_fn(name, method);
|
||||
self
|
||||
}
|
||||
|
@@ -143,11 +143,11 @@ impl Engine {
|
||||
/// This method will be removed in the next major version.
|
||||
#[deprecated(since = "1.9.1", note = "use `register_fn` instead")]
|
||||
#[inline(always)]
|
||||
pub fn register_result_fn<N, A, F, R, S>(&mut self, name: N, func: F) -> &mut Self
|
||||
where
|
||||
N: AsRef<str> + Into<Identifier>,
|
||||
F: RegisterNativeFunction<A, R, RhaiResultOf<S>>,
|
||||
{
|
||||
pub fn register_result_fn<A, R, S>(
|
||||
&mut self,
|
||||
name: impl AsRef<str> + Into<Identifier>,
|
||||
func: impl RegisterNativeFunction<A, R, RhaiResultOf<S>>,
|
||||
) -> &mut Self {
|
||||
self.register_fn(name, func)
|
||||
}
|
||||
/// Register a getter function for a member of a registered type with the [`Engine`].
|
||||
|
@@ -53,11 +53,11 @@ impl Engine {
|
||||
/// # }
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn register_fn<N, A, F, R, S>(&mut self, name: N, func: F) -> &mut Self
|
||||
where
|
||||
N: AsRef<str> + Into<Identifier>,
|
||||
F: RegisterNativeFunction<A, R, S>,
|
||||
{
|
||||
pub fn register_fn<A, R, S, F: RegisterNativeFunction<A, R, S>>(
|
||||
&mut self,
|
||||
name: impl AsRef<str> + Into<Identifier>,
|
||||
func: F,
|
||||
) -> &mut Self {
|
||||
let param_types = F::param_types();
|
||||
|
||||
#[cfg(feature = "metadata")]
|
||||
@@ -109,16 +109,12 @@ impl Engine {
|
||||
///
|
||||
/// To access the first mutable parameter, use `args.get_mut(0).unwrap()`
|
||||
#[inline(always)]
|
||||
pub fn register_raw_fn<N, T>(
|
||||
pub fn register_raw_fn<T: Variant + Clone>(
|
||||
&mut self,
|
||||
name: N,
|
||||
name: impl AsRef<str> + Into<Identifier>,
|
||||
arg_types: impl AsRef<[TypeId]>,
|
||||
func: impl Fn(NativeCallContext, &mut FnCallArgs) -> RhaiResultOf<T> + SendSync + 'static,
|
||||
) -> &mut Self
|
||||
where
|
||||
N: AsRef<str> + Into<Identifier>,
|
||||
T: Variant + Clone,
|
||||
{
|
||||
) -> &mut Self {
|
||||
self.global_namespace_mut().set_raw_fn(
|
||||
name,
|
||||
FnNamespace::Global,
|
||||
|
Reference in New Issue
Block a user