From 8248c9999dad045d4b5ba7e0760de61d33e4ca43 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 23 Feb 2021 12:52:47 +0800 Subject: [PATCH] Add split version for chars. --- src/packages/string_more.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/packages/string_more.rs b/src/packages/string_more.rs index 427627fb..11357d88 100644 --- a/src/packages/string_more.rs +++ b/src/packages/string_more.rs @@ -372,6 +372,10 @@ mod string_functions { format!("{:?}{}", array, string) } #[rhai_fn(name = "split")] + pub fn chars(string: &str) -> Array { + string.chars().map(Into::::into).collect() + } + #[rhai_fn(name = "split")] pub fn split_at(string: ImmutableString, start: INT) -> Array { if start <= 0 { vec!["".into(), string.into()]