This crate provides a
LazyCell struct which acts as a lazily filled
RefCell, the inner contents cannot be borrowed for the lifetime of
the entire object, but only of the borrows returned. A
LazyCell is a
RefCell which allows borrows to be tied to the lifetime of
the outer object.
The following example shows a quick example of the basic functionality of
use lazycell::LazyCell; let lazycell = LazyCell::new(); assert_eq!(lazycell.borrow(), None); assert!(!lazycell.filled()); lazycell.fill(1).ok(); assert!(lazycell.filled()); assert_eq!(lazycell.borrow(), Some(&1)); assert_eq!(lazycell.into_inner(), Some(1));
AtomicLazyCell is a variant that uses an atomic variable to manage
coordination in a thread-safe fashion. The limitation of an
is that after it is initialized, it can't be modified.
A lazily filled and thread-safe
A lazily filled