lazy_static is a very popular crate. Years ago it had no better alternatives for certain tasks. But today, are there still any reasons to choose lazy_static
over the newer once_cell or the upcoming LazyLock?
Asked
Active
Viewed 5,683 times
12

thatfellowoveryonder
- 301
- 3
- 13

at54321
- 8,726
- 26
- 46
2 Answers
5
If you'd like to support #![no_std]
platforms, you may still prefer to use lazy_static
. As per the once_cell
documentation :
Unlike
once_cell
,lazy_static
supports spinlock-based implementation of blocking which works with#![no_std]
.

antonok
- 516
- 6
- 9
4
once_cell
and LazyLock
have a minimum support version of the compiler. For earlier versions of it you would probably want to stick to lazy_static
which has served it purpose pretty well when less features were available.

thatfellowoveryonder
- 301
- 3
- 13

Netwave
- 40,134
- 6
- 50
- 93