Guarantee that icu initialization is called one time only.
#[cfg(windows)]
pub fn init() {
- use std::env;
+ use std::{env, sync::Once};
+ ONCE.call_once(|| {
let icudtl = include_bytes!(concat!(env!("OUT_DIR"), "/skia/icudtl.dat"));
#[cfg(feature = "embed-icudtl")]
@@ -23,6 +24,8 @@ pub fn init() {
fs::write(path, &icu_dtl[..])
.expect("failed to write icudtl.dat into the current executable's directory");
}
+ });
+ static ONCE: Once = Once::new();
}
#[cfg(not(windows))]
