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

@@ -140,6 +140,7 @@ mod string_functions {
pub fn add_prepend_unit(_x: (), s: ImmutableString) -> ImmutableString {
s
}
#[rhai_fn(name = "+=")]
#[inline(always)]
pub fn append_char(s: &mut ImmutableString, ch: char) {
@@ -151,17 +152,12 @@ mod string_functions {
*s += &add;
}
#[rhai_fn(name = "len", get = "len")]
#[inline(always)]
pub fn len(s: &mut ImmutableString) -> INT {
s.chars().count() as INT
}
#[rhai_fn(get = "len")]
#[inline(always)]
pub fn len_prop(s: &mut ImmutableString) -> INT {
len(s)
}
#[inline(always)]
pub fn clear(s: &mut ImmutableString) {
s.make_mut().clear();