-
Notifications
You must be signed in to change notification settings - Fork 95
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
Update documentation for Once
to reference std::sync::OnceLock
.
#159
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,7 @@ use core::{cell::UnsafeCell, fmt, marker::PhantomData, mem::MaybeUninit}; | |
|
||
/// A primitive that provides lazy one-time initialization. | ||
/// | ||
/// Unlike its `std::sync` equivalent, this is generalized such that the closure returns a | ||
/// value to be stored by the [`Once`] (`std::sync::Once` can be trivially emulated with | ||
/// `Once`). | ||
/// This is analogous to `std::sync::OnceLock`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I think this is probably too strong a statement. They're definitely very similar, but the APIs differ enough that I'd probably go for something like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous "equivalent" was already much stronger language than "analogous," which isn't any stronger of a statement than "similar behavio[u]r." For most people, if they need a spinlock variant of |
||
/// | ||
/// Because [`Once::new`] is `const`, this primitive may be used to safely initialize statics. | ||
/// | ||
|
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.
What's the reason for removing this?
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.
Previously, we were comparing
spin::Once
tostd::sync::Once
, which didn't own the result of the initializer. Now we're comparing it toOnceLock
, which does own the result of the initializer.