cuprate
cuprate copied to clipboard
Usage of `LazyLock` over `OnceLock` + `fn`
What
This can replace any std::sync::OnceLock
+ fn
usage.
Where
Any place using OnceLock
+ fn
for LazyLock
behavior, e.g.:
https://github.com/Cuprate/cuprate/blob/929d19c4508a84d886ece03009a6fcdc5edea5c2/helper/src/fs.rs#L86-L90
How
Replace OnceLock
+ fn
with:
static _: LazyLock<T> = LazyLock::new(|| {
/* old OnceLock::get_or_init function */
});