Skip to content
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

Merged
merged 5 commits into from
Aug 28, 2022
Merged

Add a OnceCell type #27

merged 5 commits into from
Aug 28, 2022

Conversation

notgull
Copy link
Member

@notgull notgull commented Aug 23, 2022

This PR adds a OnceCell type similar to the types found in the once_cell crate and the tokio crate. It is usable from both blocking and non-blocking code.

src/once_cell.rs Outdated Show resolved Hide resolved
src/once_cell.rs Outdated Show resolved Hide resolved
Copy link
Member

@zeenix zeenix left a 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> {
Copy link
Collaborator

@taiki-e taiki-e Aug 24, 2022

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

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

src/once_cell.rs Show resolved Hide resolved
@notgull notgull merged commit 05fed2a into smol-rs:master Aug 28, 2022
@notgull
Copy link
Member Author

notgull commented Sep 5, 2022

@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.

@taiki-e
Copy link
Collaborator

taiki-e commented Sep 5, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants