pub struct UnsafeSyncCell<T>(/* private fields */);
Expand description
Sync version of UnsafeCell<MaybeUninit<T>>
.
While it should not be used outside of this crate, it may be useful in certain scenarios.
Implementations§
Source§impl<T> UnsafeSyncCell<T>
impl<T> UnsafeSyncCell<T>
Sourcepub fn check_zeroed(ptr: *const T) -> bool
pub fn check_zeroed(ptr: *const T) -> bool
Checks whether the memory pointed to by ptr
, for a certain type T
, is composed entirely of zeros.
Sourcepub unsafe fn take_inner(&self) -> T
pub unsafe fn take_inner(&self) -> T
Takes inner value, replacing its old location with zeros.
§Safety
The cell will be uninitialised and so must be initialised again with Self::as_mut_ptr
.
Sourcepub unsafe fn inner_duplicate(&self) -> T
pub unsafe fn inner_duplicate(&self) -> T
Reads and duplicates the value.
For more information on MaybeUninit
, refer to
the Rust documentation.
§Safety
The inner value must be initialised (i.e., properly constructed).
Sourcepub unsafe fn inner_ref<'a>(&self) -> &'a T
pub unsafe fn inner_ref<'a>(&self) -> &'a T
Returns a reference to inner value.
§Safety
Inner value must be initialised (i.e., properly constructed).
Sourcepub unsafe fn inner_ref_mut<'a>(&self) -> &'a mut T
pub unsafe fn inner_ref_mut<'a>(&self) -> &'a mut T
Returns a mutable reference to inner value.
§Safety
Not to be used to initialise inner value! Use Self::as_mut_ptr
, instead.
Sourcepub fn as_mut_ptr(&self) -> *mut T
pub fn as_mut_ptr(&self) -> *mut T
Gets a mutable pointer to the contained value.
See MaybeUninit::as_mut_ptr
.
Trait Implementations§
Source§impl<T: Clone> Clone for UnsafeSyncCell<T>
impl<T: Clone> Clone for UnsafeSyncCell<T>
Source§impl<T: Default> Default for UnsafeSyncCell<T>
impl<T: Default> Default for UnsafeSyncCell<T>
Source§fn default() -> UnsafeSyncCell<T>
fn default() -> UnsafeSyncCell<T>
Creates an UnsafeSyncCell
, with the Default
value for T.
Source§impl<T> Drop for UnsafeSyncCell<T>
impl<T> Drop for UnsafeSyncCell<T>
Source§impl<T> From<T> for UnsafeSyncCell<T>
impl<T> From<T> for UnsafeSyncCell<T>
Source§fn from(t: T) -> UnsafeSyncCell<T>
fn from(t: T) -> UnsafeSyncCell<T>
Creates a new UnsafeSyncCell<T>
containing the given value.