logo
pub trait UnsafeCellDeref<'a, T>: SealedUnsafeCell {
    unsafe fn deref_mut(self) -> &'a mut T;
    unsafe fn deref(self) -> &'a T;
    unsafe fn read(self) -> T
    where
        T: Copy
; }
Expand description

Extension trait for helper methods on UnsafeCell

Required Methods

Safety
  • The returned value must be unique and not alias any mutable or immutable references to the contents of the UnsafeCell.
  • At all times, you must avoid data races. If multiple threads have access to the same UnsafeCell, then any writes must have a proper happens-before relation to all other accesses or use atomics (UnsafeCell docs for reference).
Safety
  • For the lifetime 'a of the returned value you must not construct a mutable reference to the contents of the UnsafeCell.
  • At all times, you must avoid data races. If multiple threads have access to the same UnsafeCell, then any writes must have a proper happens-before relation to all other accesses or use atomics (UnsafeCell docs for reference).

Returns a copy of the contained value.

Safety
  • The UnsafeCell must not currently have a mutable reference to its content.
  • At all times, you must avoid data races. If multiple threads have access to the same UnsafeCell, then any writes must have a proper happens-before relation to all other accesses or use atomics (UnsafeCell docs for reference).

Implementations on Foreign Types

Implementors