Trait bevy::ecs::ptr::UnsafeCellDeref

source ·
pub trait UnsafeCellDeref<'a, T>: SealedUnsafeCell {
    // Required methods
    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§

source

unsafe fn deref_mut(self) -> &'a mut T

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).
source

unsafe fn deref(self) -> &'a T

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).
source

unsafe fn read(self) -> T
where T: Copy,

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).

Implementors§

source§

impl<'a, T> UnsafeCellDeref<'a, T> for &'a UnsafeCell<T>