Add split version for chars.

This commit is contained in:
Stephen Chung 2021-02-23 12:52:47 +08:00
parent e88713611c
commit 8248c9999d

View File

@ -372,6 +372,10 @@ mod string_functions {
format!("{:?}{}", array, string) format!("{:?}{}", array, string)
} }
#[rhai_fn(name = "split")] #[rhai_fn(name = "split")]
pub fn chars(string: &str) -> Array {
string.chars().map(Into::<Dynamic>::into).collect()
}
#[rhai_fn(name = "split")]
pub fn split_at(string: ImmutableString, start: INT) -> Array { pub fn split_at(string: ImmutableString, start: INT) -> Array {
if start <= 0 { if start <= 0 {
vec!["".into(), string.into()] vec!["".into(), string.into()]