pub struct SyncUnsafeCell<T>where
T: ?Sized,{ /* private fields */ }
sync_unsafe_cell #95439)
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.
impl<T> SyncUnsafeCell<T>
pub const fn new(value: T) -> SyncUnsafeCell<T>
sync_unsafe_cell #95439)
Constructs a new instance of SyncUnsafeCell which will wrap the specified value.
pub const fn into_inner(self) -> T
sync_unsafe_cell #95439)
Unwraps the value, consuming the cell.
impl<T> SyncUnsafeCell<T>where
T: ?Sized,pub const fn get(&self) -> *mut T
sync_unsafe_cell #95439)
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
pub const fn get_mut(&mut self) -> &mut T
sync_unsafe_cell #95439)
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.
pub const fn raw_get(this: *const SyncUnsafeCell<T>) -> *mut T
sync_unsafe_cell #95439)
Gets a mutable pointer to the wrapped value.
See UnsafeCell::get for details.
impl<T> Debug for SyncUnsafeCell<T>where
T: ?Sized,fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
impl<T> Default for SyncUnsafeCell<T>where
T: Default,fn default() -> SyncUnsafeCell<T>
Creates an SyncUnsafeCell, with the Default value for T.
impl<T> From<T> for SyncUnsafeCell<T>
fn from(t: T) -> SyncUnsafeCell<T>
Creates a new SyncUnsafeCell<T> containing the given value.
impl<T, U> CoerceUnsized<SyncUnsafeCell<U>> for SyncUnsafeCell<T>where
T: CoerceUnsized<U>,impl<T, U> DispatchFromDyn<SyncUnsafeCell<U>> for SyncUnsafeCell<T>where
T: DispatchFromDyn<U>,impl<T> PinCoerceUnsized for SyncUnsafeCell<T>where
T: ?Sized,impl<T> Sync for SyncUnsafeCell<T>where
T: Sync + ?Sized,impl<T> !Freeze for SyncUnsafeCell<T>
impl<T> !RefUnwindSafe for SyncUnsafeCell<T>
impl<T> Send for SyncUnsafeCell<T>where
T: Send + ?Sized,impl<T> Unpin for SyncUnsafeCell<T>where
T: Unpin + ?Sized,impl<T> UnwindSafe for SyncUnsafeCell<T>where
T: UnwindSafe + ?Sized,impl<T> Any for Twhere
T: 'static + ?Sized,impl<T> Borrow<T> for Twhere
T: ?Sized,impl<T> BorrowMut<T> for Twhere
T: ?Sized,impl<T> From<!> for T
fn from(t: !) -> T
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for Twhere
U: From<T>,fn into(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<U> for Twhere
U: Into<T>,type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/cell/struct.SyncUnsafeCell.html