Move most packages to modules.

This commit is contained in:
Stephen Chung
2020-08-22 22:26:49 +08:00
parent 5d6fdba24d
commit 211ce54973
6 changed files with 511 additions and 510 deletions

View File

@@ -59,9 +59,6 @@ def_package!(crate:MoreStringPackage:"Additional string utilities, including str
#[cfg(not(feature = "no_float"))]
reg_functions!(lib += float; f32, f64);
#[cfg(not(feature = "no_index"))]
lib.combine_flatten(exported_module!(index_functions));
lib.combine_flatten(exported_module!(string_functions));
lib.set_raw_fn(
@@ -343,21 +340,20 @@ mod string_functions {
pub fn replace_char(s: &mut ImmutableString, find: char, sub: char) {
*s = s.replace(&find.to_string(), &sub.to_string()).into();
}
}
#[cfg(not(feature = "no_index"))]
#[export_module]
mod index_functions {
use crate::engine::Array;
#[cfg(not(feature = "no_index"))]
pub mod arrays {
use crate::engine::Array;
#[rhai_fn(name = "+")]
#[inline]
pub fn append(x: &mut ImmutableString, y: Array) -> String {
format!("{}{:?}", x, y)
}
#[rhai_fn(name = "+")]
#[inline]
pub fn prepend(x: &mut Array, y: ImmutableString) -> String {
format!("{:?}{}", x, y)
#[rhai_fn(name = "+")]
#[inline]
pub fn append(x: &mut ImmutableString, y: Array) -> String {
format!("{}{:?}", x, y)
}
#[rhai_fn(name = "+")]
#[inline]
pub fn prepend(x: &mut Array, y: ImmutableString) -> String {
format!("{:?}{}", x, y)
}
}
}