Deprecate Module::set_fn_XXX API.
This commit is contained in:
@@ -141,7 +141,7 @@ macro_rules! reg_range {
|
||||
($lib:ident | $x:expr => $( $y:ty ),*) => {
|
||||
$(
|
||||
$lib.set_iterator::<Range<$y>>();
|
||||
let hash = $lib.set_fn_2($x, get_range::<$y>);
|
||||
let hash = $lib.set_native_fn($x, get_range::<$y>);
|
||||
$lib.update_fn_metadata(hash, &[
|
||||
concat!("from: ", stringify!($y)),
|
||||
concat!("to: ", stringify!($y)),
|
||||
@@ -152,7 +152,7 @@ macro_rules! reg_range {
|
||||
($lib:ident | step $x:expr => $( $y:ty ),*) => {
|
||||
$(
|
||||
$lib.set_iterator::<StepRange<$y>>();
|
||||
let hash = $lib.set_fn_3($x, get_step_range::<$y>);
|
||||
let hash = $lib.set_native_fn($x, get_step_range::<$y>);
|
||||
$lib.update_fn_metadata(hash, &[
|
||||
concat!("from: ", stringify!($y)),
|
||||
concat!("to: ", stringify!($y)),
|
||||
@@ -248,10 +248,10 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, {
|
||||
|
||||
lib.set_iterator::<StepDecimalRange>();
|
||||
|
||||
let hash = lib.set_fn_2("range", |from, to| StepDecimalRange::new(from, to, Decimal::one()));
|
||||
let hash = lib.set_native_fn("range", |from, to| StepDecimalRange::new(from, to, Decimal::one()));
|
||||
lib.update_fn_metadata(hash, &["from: Decimal", "to: Decimal", "Iterator<Item=Decimal>"]);
|
||||
|
||||
let hash = lib.set_fn_3("range", |from, to, step| StepDecimalRange::new(from, to, step));
|
||||
let hash = lib.set_native_fn("range", |from, to, step| StepDecimalRange::new(from, to, step));
|
||||
lib.update_fn_metadata(hash, &["from: Decimal", "to: Decimal", "step: Decimal", "Iterator<Item=Decimal>"]);
|
||||
}
|
||||
});
|
||||
|
@@ -53,8 +53,7 @@ pub trait Package {
|
||||
/// Macro that makes it easy to define a _package_ (which is basically a shared [module][Module])
|
||||
/// and register functions into it.
|
||||
///
|
||||
/// Functions can be added to the package using the standard module methods such as
|
||||
/// [`set_fn_2`][Module::set_fn_2], [`set_fn_3_mut`][Module::set_fn_3_mut], [`set_fn_0`][Module::set_fn_0] etc.
|
||||
/// Functions can be added to the package using [`Module::set_native_fn`].
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
@@ -69,7 +68,7 @@ pub trait Package {
|
||||
/// def_package!(rhai:MyPackage:"My super-duper package", lib,
|
||||
/// {
|
||||
/// // Load a binary function with all value parameters.
|
||||
/// lib.set_fn_2("my_add", add);
|
||||
/// lib.set_native_fn("my_add", add);
|
||||
/// });
|
||||
/// ```
|
||||
#[macro_export]
|
||||
|
Reference in New Issue
Block a user