Use multiple renames to simplify plugins.

This commit is contained in:
Stephen Chung
2020-09-08 18:01:34 +08:00
parent 38ccb9e8f6
commit d41fde9c31
7 changed files with 25 additions and 84 deletions

View File

@@ -30,7 +30,8 @@ mod time_functions {
pub fn timestamp() -> Instant {
Instant::now()
}
#[rhai_fn(return_raw)]
#[rhai_fn(name = "elapsed", get = "elapsed", return_raw)]
pub fn elapsed(timestamp: &mut Instant) -> Result<Dynamic, Box<EvalAltResult>> {
#[cfg(not(feature = "no_float"))]
{
@@ -52,12 +53,6 @@ mod time_functions {
}
}
#[rhai_fn(get = "elapsed", return_raw)]
#[inline(always)]
pub fn elapsed_prop(timestamp: &mut Instant) -> Result<Dynamic, Box<EvalAltResult>> {
elapsed(timestamp)
}
#[rhai_fn(return_raw, name = "-")]
pub fn time_diff(ts1: Instant, ts2: Instant) -> Result<Dynamic, Box<EvalAltResult>> {
#[cfg(not(feature = "no_float"))]