-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Relax Once so I can use it for arbitrary things that should run once. #2467
Comments
I'm assuming that you are referring to |
yes.
yes, but by relaxing that requirement, it can still be used with statics.
why not? |
I agree, there's no good reason for |
I would like to also mention [spin-rs] doesnt have this problem either. with my limited knowledge of lock free code, I looked at std::Once::Once, an example use case where you would want to use once is to is to create a thunk library. thunks because they are simply lazy expressions, are not to be used for statics |
The |
This issue has been fixed in master (see above), and can be closed, I think. |
More specifically, a confusing but ever-so-common construct is:
and it's bad for many reasons:
maybe you'll get warnings about unused struct fields or w/e but I'd much rather be able to just write:
and I can't do that with the standard Once. the standard Once is not standard enough - instead, it's too niche.
so, can we get nice Once? all it takes is to remove an
'static
lifetime bounds.The text was updated successfully, but these errors were encountered: