init_static

Function init_static 

Source
pub async fn init_static() -> Result<(), InitError>
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;
use std::error::Error;

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

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    init_static().await?;
    println!("{}", *VALUE);
    Ok(())
}