-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Implemented in #53027
I propose to expose a way to check if a
Once
instance is initialized.I need it in
once_cell
.OnceCell
is effetively a pair of(Once, UnsafeCell<Option<T>>)
, which can set theT
only once. Because I can't check ifOnce
is initialized, I am forced to add an indirection and check the value of ptr instead:The
parking_lot
's version ofOnce
exposes the state as an enum: https://docs.rs/parking_lot/0.6.3/parking_lot/struct.Once.html#method.state.I suggest, for now, just to add a simple
bool
function: this fits my use-case perfectly, exposes less implementation details, and is forward-compatible with more fine-grained state checking.
Metadata
Metadata
Assignees
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.