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

@@ -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()