Skip to main content

init_static

Function init_static 

Source
pub async fn init_static() -> Result<()>
Expand description

Runs initialization for all statics declared with init_static!.

This function iterates over all init functions registered via the macro and executes them once. Call this early in your program (e.g., at the beginning of main()) before accessing any InitStatic values.

ยงExamples

use init_static::init_static;

init_static! {
    static VALUE: u32 = "42".parse()?;
}

#[tokio::main]
async fn main() {
    init_static().await.unwrap();
    println!("{}", *VALUE);
}