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