On Wed, Jul 2, 2025 at 3:54 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote: > > "Alice Ryhl" <aliceryhl@xxxxxxxxxx> writes: > > > On Wed, Jul 2, 2025 at 3:19 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote: > >> > >> Introduce the `OnceLock` type, a container that can only be written once. > >> The container uses an internal atomic to synchronize writes to the internal > >> value. > >> > >> Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx> > > > > This type provides no way to wait for initialization to finish if it's > > ongoing. Do you not need that? > > I don't, and in my use case it would cause a deadlock to wait. Anyway, > it might be useful to others. Would you add it now, or wait for a user? Waiting would require additional fields so it should probably be a different type. It's more that we probably want the OnceLock name for that other type for consistency with stdlib, so perhaps this should be renamed? The name could be SetOnce or similar. Alice