pub struct OncePtr<T>(/* private fields */);
Expand description
An atomic pointer that can only be initialized once.
Implementations§
Source§impl<T> OncePtr<T>
impl<T> OncePtr<T>
Sourcepub fn load(&self) -> Option<&T>
pub fn load(&self) -> Option<&T>
Load the atomic store and return a reference to the underlying data or None
if the store is not initialized yet.
Sourcepub unsafe fn load_unchecked(&self) -> &T
pub unsafe fn load_unchecked(&self) -> &T
Load the atomic store and return a reference to the underlying data without checking if it’s null.
§Safety
It is up to the caller to ensure that the pointer is not null.
Sourcepub fn load_mut(&mut self) -> Option<&mut T>
pub fn load_mut(&mut self) -> Option<&mut T>
Load the atomic store and return a mutable reference to the underlying data or
None
if the store is not initialized yet.
This is safe because the mutable reference guarantees that no other threads are concurrently accessing the atomic data.
Sourcepub unsafe fn load_mut_unchecked(&mut self) -> &mut T
pub unsafe fn load_mut_unchecked(&mut self) -> &mut T
Load the atomic store and return a mutable reference to the underlying data without checking if it’s null.
§Safety
It is up to the caller to ensure that the pointer is not null.
Sourcepub fn into_inner(self) -> Option<T>
pub fn into_inner(self) -> Option<T>
Returns the data owned by this store.