Overview of once_cell types
masteronce_cell provides cell-like types that can be assigned at most once and provide direct access to the stored contents. It supports arbitrary non-Copy types.
There are two main modules:
unsync::OnceCell: For single-threaded use.sync::OnceCell: For thread-safe, synchronized use.
Because of the single assignment restriction, the get method can return a direct reference &T instead of requiring a guard like Ref<T> or MutexGuard<T>.
impl OnceCell<T> {
fn new() -> OnceCell<T> { ... }
fn set(&self, value: T) -> Result<(), T> { ... }
fn get(&self) -> Option<&T> { ... }
}