-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Recommend using Once::new()
instead of ONCE_INIT
?
#61746
Comments
Can we just deprecate it? |
Why is |
Similarly, the initializers for the |
"There should be only one way of doing it"™️ 🙂 I saw someone today get quite confused today as to why both existed in the first place, which required an explanation of |
/me Prepares plans to deprecate In all seriousness, imo someone's confusion as to why both existed and "only one way to do it" is a rather weak justification for churn when the old way isn't harmful in any way.
Seems fine. |
We deprecate things like ONCE_INIT 3 releases after their replacements (in this case Once::new specifically being a const fn) were added. I can't find in the release notes when that happened, but if someone tracks it down, it should be an easy PR! |
@sfackler |
😬 |
Was it callable as a const fn in 1.2.0? |
The const-ness was made stable in the same PR as for AtomicUsize::new: https://github.com/rust-lang/rust/pull/46287/files#diff-80754b8db8699947d7b2a43a9cc17dedL159 |
Once::new() has been a stable const fn for a while now. Closes rust-lang#61746
…xcrichton Deprecate ONCE_INIT Once::new() has been a stable const fn for a while now. Closes rust-lang#61746
Once::new() has been a stable const fn for a while now. Closes rust-lang#61746
…xcrichton Deprecate ONCE_INIT in future 1.38 release Once::new() has been a stable const fn for a while now. Closes rust-lang#61746
std::sync::ONCE_INIT
is in effect just an alias tostd::sync::Once::new()
, anyone using the former can use the latter since v1.2.0. I guess we can't outright deprecateONCE_INIT
given our backwards compatibility policy, but I would like to lint on its usage and at the very least call it out in the documentation ("useOnce::new()
instead").This also opens the conversation around the larger problem of what to do with the parts of the API that would get superseded by new features, like const generics, or in this case const fns.
The text was updated successfully, but these errors were encountered: