Macro irox_tools::static_init
source · macro_rules! static_init { ($name:ident,$out:ty,$($init:tt)+) => { ... }; }
Expand description
Creates a static lazy initialization variable function.
static_init!(get_data, String, {
"This could be an expensive operation!".to_string()
});expands to:
pub fn get_data() -> &'static String {
static VARBL: std::sync::OnceLock<String> = std::sync::OnceLock::new();
VARBL.get_or_init(|| {
"This could be an expensive operation!".to_string()
})
}