2 releases
0.1.2 | May 30, 2024 |
---|---|
0.1.1 | May 30, 2024 |
0.1.0 |
|
#127 in Caching
5KB
71 lines
lazier_static
Description
A thin layer around std::sync::OnceLock
providing cached, lazy, static initialization.
Examples
use lazier_static::*;
lazier_static! {
fn hello_world() -> &str {
"Hello, World!"
}
fn number() -> i32 {
10 * 32
}
}
fn main() {
println!("{}", number());
}
Usage
cargo
command
cargo add lazier_static
Cargo.toml
lazier_static = "0.1.2"
License
MIT OR Apache-2.0
lib.rs
:
lazier_static
A thin wrapper around std::sync::OnceLock
providing cached, static, lazy initialization.
use lazier_static::*;
lazier_static! {
fn hello_world() -> &str {
"Hello, World!"
}
}
//...
fn main() {
println!("{}", hello_world());
}
License
MIT OR Apache-2.0