-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace lazy_static with once_cell #3187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of this. lazy_static
has some other (potential) issues (rust-lang-nursery/lazy-static.rs#150, rust-lang/futures-rs#1485 (comment)).
This PR is fine as a first step. However, I am noticing that Instead, we may consider vendoring |
Motivation
once_cell
is a macro-free alternative tolazy_static
. ItsLazy
type has the same API aslazy_static
, but it will not use any "macro magic" and it might be more clear to read by non-experienced Rust developers.This solution is being proposed to be implemented at the Rust standard library level with an RFC. This could be an opportunity to migrate to the new solution and to check that everything is working correctly in Tokio.
Furthermore, as per this comment, it seems that due to a possible compiler bug, using
once_cell
is noticeably faster thanlazy_static
in certain hot get operations.Solution
This PR replaces all mentions to
lazy_static
byonce_cell
using the built-inLazy
type.