Use immutable strings.

This commit is contained in:
Stephen Chung
2020-05-25 13:44:28 +08:00
parent bbed4c6ef4
commit 99ea2b33c9
14 changed files with 251 additions and 191 deletions

View File

@@ -4,9 +4,9 @@ use crate::any::{Dynamic, Variant};
use crate::def_package;
use crate::engine::Array;
use crate::module::FuncReturn;
use crate::parser::INT;
use crate::parser::{ImmutableString, INT};
use crate::stdlib::{any::TypeId, boxed::Box, string::String};
use crate::stdlib::{any::TypeId, boxed::Box};
// Register array utility functions
fn push<T: Variant + Clone>(list: &mut Array, item: T) -> FuncReturn<()> {
@@ -45,9 +45,9 @@ macro_rules! reg_tri {
#[cfg(not(feature = "no_index"))]
def_package!(crate:BasicArrayPackage:"Basic array utilities.", lib, {
reg_op!(lib, "push", push, INT, bool, char, String, Array, ());
reg_tri!(lib, "pad", pad, INT, bool, char, String, Array, ());
reg_tri!(lib, "insert", ins, INT, bool, char, String, Array, ());
reg_op!(lib, "push", push, INT, bool, char, ImmutableString, Array, ());
reg_tri!(lib, "pad", pad, INT, bool, char, ImmutableString, Array, ());
reg_tri!(lib, "insert", ins, INT, bool, char, ImmutableString, Array, ());
lib.set_fn_2_mut("append", |x: &mut Array, y: Array| {
x.extend(y);