From 09b75ed1a331d636f0905e35dabbca2be12634e2 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 17 Aug 2020 10:00:50 +0800 Subject: [PATCH] Fix bug in strings package. --- src/packages/string_more.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/packages/string_more.rs b/src/packages/string_more.rs index e21d039e..087e8e90 100644 --- a/src/packages/string_more.rs +++ b/src/packages/string_more.rs @@ -23,12 +23,12 @@ macro_rules! gen_concat_functions { #[export_fn] pub fn append_func(x: ImmutableString, y: $arg_type) -> String { - super::super::append(x, y) + super::super::add_append(x, y) } #[export_fn] pub fn prepend_func(x: $arg_type, y: ImmutableString) -> String { - super::super::prepend(x, y) + super::super::add_prepend(x, y) } } )* } @@ -120,10 +120,10 @@ def_package!(crate:MoreStringPackage:"Additional string utilities, including str ); }); -fn prepend(x: T, y: ImmutableString) -> String { +fn add_prepend(x: T, y: ImmutableString) -> String { format!("{}{}", x, y) } -fn append(x: ImmutableString, y: T) -> String { +fn add_append(x: ImmutableString, y: T) -> String { format!("{}{}", x, y) } @@ -144,18 +144,18 @@ gen_concat_functions!(float => f32, f64); #[export_module] mod string_functions { #[rhai_fn(name = "+")] - pub fn append_unit(s: ImmutableString, _x: ()) -> ImmutableString { + pub fn add_append_unit(s: ImmutableString, _x: ()) -> ImmutableString { s } #[rhai_fn(name = "+")] - pub fn prepend_unit(_x: (), s: ImmutableString) -> ImmutableString { + pub fn add_prepend_unit(_x: (), s: ImmutableString) -> ImmutableString { s } - #[rhai_fn(name = "+")] + #[rhai_fn(name = "+=")] pub fn append_char(s: &mut ImmutableString, ch: char) { *s += ch; } - #[rhai_fn(name = "+")] + #[rhai_fn(name = "+=")] pub fn append_string(s: &mut ImmutableString, add: ImmutableString) { *s += &add; }