split off to_chars_array
This commit is contained in:
parent
c740571f0d
commit
aad5c50f84
19
build.rs
19
build.rs
@ -82,24 +82,7 @@ fn main() {
|
||||
let chars_array = format!(
|
||||
"const VALID_EXTRA_CHARS: [char; {}] = {};",
|
||||
filtered_chars.len(),
|
||||
[
|
||||
"[",
|
||||
&filtered_chars
|
||||
.iter()
|
||||
.map(|c| format!("'{}'", c.escape_unicode()))
|
||||
.enumerate()
|
||||
.map(|(i, x)| {
|
||||
// Add comma and space if needed
|
||||
match filtered_chars.len() > i + 1 {
|
||||
true => x + ", ",
|
||||
false => x,
|
||||
}
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.concat(),
|
||||
"]",
|
||||
]
|
||||
.concat()
|
||||
to_chars_array(filtered_chars),
|
||||
);
|
||||
let path = Path::new(&env::var("OUT_DIR").unwrap()).join("valid_chars.rs");
|
||||
let mut file = BufWriter::new(File::create(&path).expect("Could not save compressed_data"));
|
||||
|
||||
@ -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! {
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
||||
@ -201,3 +201,12 @@ fn to_unicode_hash() {
|
||||
use ytbn_graphing_software::to_unicode_hash;
|
||||
assert_eq!(to_unicode_hash('\u{1f31e}'), "\\U1F31E");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_chars_array() {
|
||||
use ytbn_graphing_software::to_chars_array;
|
||||
assert_eq!(
|
||||
to_chars_array(vec!['\u{1f31e}', '\u{2d12c}']),
|
||||
r#"['\u{1f31e}', '\u{2d12c}']"#
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user