3 ms·
I'd suggest once_cell instead of lazy_static. No macros, faster compiles. https://crates.io/crates/once_cell https://crates.io/crates/once_cell
by johnsoft 6y ago
I'd suggest once_cell instead of lazy_static. No macros, faster compiles.
https://crates.io/crates/once_cell https://crates.io/crates/once_cell
- dathinab 6y agoYes, but it's more than that. once_cell allows you more ways to do lazy initialization. Like by using `once_cell::sync::OnceCell` instead of `once_cell::sync::Lazy` you can determine the init function when trying to access the once cell. For many cases `Lazy` is what you want but for some `OnceCell` makes it just so much easier. And then you also can use the types outside of a "lazy initialized static/global" use case. So generally it's better (by now).
- archseer 6y agoIt's also on track to be available in std: https://github.com/rust-lang/rust/pull/72414 https://github.com/rust-lang/rust/pull/72414 https://github.com/rust-lang/rust/issues/74465 https://github.com/rust-lang/rust/issues/74465