Struct SyncUnsafeCell

struct SyncUnsafeCell<T: ?Sized> { ... }

UnsafeCell, but Sync.

This is just an UnsafeCell, except it implements Sync if T implements Sync.

UnsafeCell doesn't implement Sync, to prevent accidental mis-use. You can use SyncUnsafeCell instead of UnsafeCell to allow it to be shared between threads, if that's intentional. Providing proper synchronization is still the task of the user, making this type just as unsafe to use.

See UnsafeCell for details.

Implementations

impl<T> SyncUnsafeCell<T>

const fn new(value: T) -> Self

Constructs a new instance of SyncUnsafeCell which will wrap the specified value.

const fn into_inner(self: Self) -> T

Unwraps the value, consuming the cell.

impl<T: ?Sized> SyncUnsafeCell<T>

const fn get(self: &Self) -> *mut T

Gets a mutable pointer to the wrapped value.

This can be cast to a pointer of any kind. Ensure that the access is unique (no active references, mutable or not) when casting to &mut T, and ensure that there are no mutations or mutable aliases going on when casting to &T

const fn get_mut(self: &mut Self) -> &mut T

Returns a mutable reference to the underlying data.

This call borrows the SyncUnsafeCell mutably (at compile-time) which guarantees that we possess the only reference.

const fn raw_get(this: *const Self) -> *mut T

Gets a mutable pointer to the wrapped value.

See UnsafeCell::get for details.

impl<T> Any for SyncUnsafeCell<T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for SyncUnsafeCell<T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for SyncUnsafeCell<T>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> Freeze for SyncUnsafeCell<T>

impl<T> From for SyncUnsafeCell<T>

fn from(t: never) -> T

impl<T> From for SyncUnsafeCell<T>

fn from(t: T) -> SyncUnsafeCell<T>

Creates a new SyncUnsafeCell<T> containing the given value.

impl<T> From for SyncUnsafeCell<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> RefUnwindSafe for SyncUnsafeCell<T>

impl<T> Send for SyncUnsafeCell<T>

impl<T> Unpin for SyncUnsafeCell<T>

impl<T> UnwindSafe for SyncUnsafeCell<T>

impl<T, U> Into for SyncUnsafeCell<T>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for SyncUnsafeCell<T>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for SyncUnsafeCell<T>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<T: ?Sized + Sync> Sync for SyncUnsafeCell<T>

impl<T: ?Sized> Debug for crate::cell::SyncUnsafeCell<T>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<T: ?Sized> PinCoerceUnsized for SyncUnsafeCell<T>

impl<T: CoerceUnsized<U>, U> CoerceUnsized for SyncUnsafeCell<T>

impl<T: DispatchFromDyn<U>, U> DispatchFromDyn for SyncUnsafeCell<T>

impl<T: ~const Default> Default for SyncUnsafeCell<T>

fn default() -> SyncUnsafeCell<T>

Creates an SyncUnsafeCell, with the Default value for T.