pub struct InitCell<T>(/* private fields */);Expand description
A one-time initialization cell.
This is mostly intended for use in statics. The cell is safe to access,
but must be initialized before any access. There is no synchronization
to ensure initialization is observed, so you should initialize at the
beginning of the main function or using something like the ctor crate.
Implementations§
Source§impl<T> InitCell<T>
impl<T> InitCell<T>
Sourcepub fn initialized(x: T) -> Self
pub fn initialized(x: T) -> Self
Creates a new initialized InitCell. Unlike InitCell::new, this is
safe because the cell is already initialized and can be used freely.
Sourcepub unsafe fn into_inner(cell: Self) -> T
pub unsafe fn into_inner(cell: Self) -> T
Gets the inner (initialized) value of this cell.
Trait Implementations§
Source§impl<T: Ord> Ord for InitCell<T>
impl<T: Ord> Ord for InitCell<T>
Source§impl<T: PartialOrd> PartialOrd for InitCell<T>
impl<T: PartialOrd> PartialOrd for InitCell<T>
impl<T: Eq> Eq for InitCell<T>
impl<T: Send> Send for InitCell<T>
impl<T: Sync> Sync for InitCell<T>
Auto Trait Implementations§
impl<T> !Freeze for InitCell<T>
impl<T> !RefUnwindSafe for InitCell<T>
impl<T> Unpin for InitCell<T>where
T: Unpin,
impl<T> UnwindSafe for InitCell<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more