-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Replace lazy_static with once_cell #3187
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
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_cellis a macro-free alternative tolazy_static. ItsLazytype 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_cellis noticeably faster thanlazy_staticin certain hot get operations.Solution
This PR replaces all mentions to
lazy_staticbyonce_cellusing the built-inLazytype.