Are there still reasons to use lazy_static?

Viewed 1673

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?

2 Answers

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.

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].

Related