3 ms·
Yes, 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:
by dathinab 6y ago
Yes, 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