Reverse regression on string + operator.

This commit is contained in:
Stephen Chung 2021-11-05 20:34:27 +08:00
parent 231584824a
commit 46e99df9cd
2 changed files with 21 additions and 3 deletions

View File

@ -1,6 +1,15 @@
Rhai Release Notes Rhai Release Notes
================== ==================
Version 1.1.3
=============
Bug fixes
---------
* Reverses a regression on string `+` operations.
Version 1.1.2 Version 1.1.2
============= =============

View File

@ -45,19 +45,28 @@ mod string_functions {
s s
} }
#[rhai_fn(name = "append")] #[rhai_fn(name = "+", name = "append")]
pub fn add_append_str(string1: ImmutableString, string2: ImmutableString) -> ImmutableString { pub fn add_append_str(string1: ImmutableString, string2: ImmutableString) -> ImmutableString {
string1 + string2 string1 + string2
} }
#[rhai_fn(name = "append")] #[rhai_fn(name = "+", name = "append")]
pub fn add_append_char(string: ImmutableString, character: char) -> ImmutableString { pub fn add_append_char(string: ImmutableString, character: char) -> ImmutableString {
string + character string + character
} }
#[rhai_fn(name = "append")] #[rhai_fn(name = "+")]
pub fn add_prepend_char(character: char, string: ImmutableString) -> ImmutableString {
format!("{}{}", character, string).into()
}
#[rhai_fn(name = "+", name = "append")]
pub fn add_append_unit(string: ImmutableString, item: ()) -> ImmutableString { pub fn add_append_unit(string: ImmutableString, item: ()) -> ImmutableString {
let _item = item; let _item = item;
string string
} }
#[rhai_fn(name = "+")]
pub fn add_prepend_unit(_item: (), string: ImmutableString) -> ImmutableString {
string
}
#[rhai_fn(name = "len", get = "len")] #[rhai_fn(name = "len", get = "len")]
pub fn len(string: &str) -> INT { pub fn len(string: &str) -> INT {