simplify to_chars_array
This commit is contained in:
parent
7c2116d548
commit
11464135bc
@ -67,6 +67,7 @@ serde_json = "1"
|
|||||||
zstd = "0.11"
|
zstd = "0.11"
|
||||||
run_script = "0.9"
|
run_script = "0.9"
|
||||||
json5 = "0.4"
|
json5 = "0.4"
|
||||||
|
itertools = "0.10"
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
instant = "0.1"
|
instant = "0.1"
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn to_unicode_hash(c: char) -> String {
|
pub fn to_unicode_hash(c: char) -> String {
|
||||||
c.escape_unicode()
|
c.escape_unicode()
|
||||||
@ -15,16 +17,7 @@ pub fn to_chars_array(chars: Vec<char>) -> String {
|
|||||||
&chars
|
&chars
|
||||||
.iter()
|
.iter()
|
||||||
.map(|c| format!("'{}'", c.escape_unicode()))
|
.map(|c| format!("'{}'", c.escape_unicode()))
|
||||||
.enumerate()
|
.join(", "),
|
||||||
.map(|(i, x)| {
|
|
||||||
// Add comma and space if needed
|
|
||||||
match chars.len() > i + 1 {
|
|
||||||
true => x + ", ",
|
|
||||||
false => x,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
.concat(),
|
|
||||||
"]",
|
"]",
|
||||||
]
|
]
|
||||||
.concat()
|
.concat()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user