simplify to_chars_array

This commit is contained in:
Simon Gardling 2022-06-12 15:36:43 -04:00
parent 7c2116d548
commit 11464135bc
2 changed files with 4 additions and 10 deletions

View File

@ -67,6 +67,7 @@ serde_json = "1"
zstd = "0.11"
run_script = "0.9"
json5 = "0.4"
itertools = "0.10"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
instant = "0.1"

View File

@ -1,3 +1,5 @@
use itertools::Itertools;
#[allow(dead_code)]
pub fn to_unicode_hash(c: char) -> String {
c.escape_unicode()
@ -15,16 +17,7 @@ pub fn to_chars_array(chars: Vec<char>) -> String {
&chars
.iter()
.map(|c| format!("'{}'", c.escape_unicode()))
.enumerate()
.map(|(i, x)| {
// Add comma and space if needed
match chars.len() > i + 1 {
true => x + ", ",
false => x,
}
})
.collect::<Vec<String>>()
.concat(),
.join(", "),
"]",
]
.concat()