This crate provides a set of synchronized initialization primitives, which are primarily useful for lazy and one-time initialization of static variables.
Lazy type has the same functionality as the
but works without any macros.
This type is very similar to the
std::sync::Once type in the standard
library, but features a richer API.
A cell type with interior mutability that can be only written to once and only allows read access to the contained data after initialization.
Inspiration for this crate is heavily drawn from
but features clear distinctions between blocking and non-blocking operations
and support for
#[no_std] environments out of the box, by offering
additional synchronization primitives using spin-locks instead of OS reliant
Unlike many other crates, support for the
#[no_std] compatible types is
not mutually exclusive with using the types relying on the presence of the
The idea for the implementation of the
OnceCell types is also
directly inspired by the implementation in the standard library.
The reasoning behind re-implementing
Once is the fairly restricted and
partly unstable API of the version in the standard library.
Generic 'raw' types exposed through various type aliases.
Synchronized one-time and lazy initialization primitives that use spin-locks in case of concurrent accesses under contention.
Possible error variants of non-blocking fallible get calls.
Possible error variants of non-blocking initialization calls.
A type for lazy initialization of e.g. global static variables, which
provides the same functionality as the
A synchronization primitive which can be used to run a one-time global initialization.
An interior mutability cell type which allows synchronized one-time initialization and read-only access exclusively after initialization.