lazy initialization
Creating a value the first time it's needed instead of at startup.
OnceLock
Examples
static CONFIG: LazyLock<String> = LazyLock::new(|| load());runsloadon the first access only, even when several threads readCONFIG.
Creating a value the first time it's needed instead of at startup.
OnceLock
Examples
static CONFIG: LazyLock<String> = LazyLock::new(|| load()); runs load on the first access only, even when several threads read CONFIG.