split off to_chars_array

This commit is contained in:
Simon Gardling
2022-06-02 01:52:07 -04:00
parent c740571f0d
commit aad5c50f84
4 changed files with 33 additions and 19 deletions

View File

@@ -36,7 +36,7 @@ pub use crate::{
step_helper,
EguiHelper,
},
unicode_helper::to_unicode_hash,
unicode_helper::{to_chars_array, to_unicode_hash},
};
cfg_if::cfg_if! {

View File

@@ -7,3 +7,25 @@ pub fn to_unicode_hash(c: char) -> String {
.replace('}', "")
.to_uppercase()
}
#[allow(dead_code)]
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(),
"]",
]
.concat()
}