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§
sourceunsafe fn deref_mut(self) -> &'a mut T
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 (UnsafeCelldocs for reference).
sourceunsafe fn deref(self) -> &'a T
unsafe fn deref(self) -> &'a T
§Safety
- For the lifetime
'aof the returned value you must not construct a mutable reference to the contents of theUnsafeCell. - 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 (UnsafeCelldocs for reference).
sourceunsafe fn read(self) -> Twhere
T: Copy,
unsafe fn read(self) -> Twhere
T: Copy,
Returns a copy of the contained value.
§Safety
- The
UnsafeCellmust 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 (UnsafeCelldocs for reference).