-
Notifications
You must be signed in to change notification settings - Fork 733
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
use once_cell
instead of static mut
#2958
base: master
Are you sure you want to change the base?
Conversation
In light of #2949, would it be possible to use |
yeah, if we can use rust 1.70 |
If we care about compiling on the 2024 edition the MSRV would be 1.82. I mean it's nice to be ready and all but personally, I think this can be blocked until |
I'm ok with that |
Hmm, IMO OnceCell is wrong, because it's not thread-safe (and static mut is thread safe if the inner type is Sync). We need to wait for OnceLock... |
The
But I think thread-safety of |
Oops, though the std::cell::OnceCell was used, my bad :)
Yes, because with static mut you can mutate the inner type, losing the 'thread-safety' things you added in there :) Edit: nevertheless this change looks good, lets get rid of the |
Motivation
References to a
static mut
variable would become a hard error in rust 2024.Link
Issue
Solution
Use once_cell::sync::OnceCell to do the one-time global initialization.