-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add a OnceCell type #27
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.
LGTM otherwise.
/// } | ||
/// } | ||
/// ``` | ||
pub struct OnceCell<T> { |
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.
bikeshed: It is interesting that the standard library has renamed this to OnceLock.
https://doc.rust-lang.org/nightly/std/sync/struct.OnceLock.html
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.
Interesting, it looks like the name is very much in flux for std
right now. Do we wait for libstd to arrive at a proper conclusion, or do we just keep OnceCell
?
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.
OnceCell seems good to me. Other crates use the same name as well.
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.
@taiki-e Any thoughts on this? Right now this requested change is blocking the merge.
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.
Future notes: OnceLock
was decided on the final name by libstd
. It might be prudent to rename OnceCell
appropriately at the next breaking change.
@smol-rs/admins Don't release this yet. I'd like event-listener#30 to be completed so that the changes there can be reflected in the new APIs, to prevent any major version bumps being necessary. |
I guess adding no-std support to this crate would require a major version bump anyway. (no-std support would be a breaking change for users who disable the default features) |
This PR adds a
OnceCell
type similar to the types found in theonce_cell
crate and thetokio
crate. It is usable from both blocking and non-blocking code.