pub struct AtomicCell<T> { /* private fields */ }Expand description
Atomic cell with a fully safe API.
Wraps UnsafeCell to provide interior mutability without requiring T: Default.
§Safety
- The constructor guarantees correct initialisation.
- All memory operations are encapsulated.
- Panics if creation is impossible (system error).
Implementations§
Source§impl<T> AtomicCell<T>
impl<T> AtomicCell<T>
Sourcepub fn store(&self, value: T)
pub fn store(&self, value: T)
Store a new value (requires unique write access, no concurrent reads).
Sourcepub const fn new(value: T) -> AtomicCell<T>
pub const fn new(value: T) -> AtomicCell<T>
Create a new atomic cell.
Sourcepub fn try_new(value: T) -> Result<AtomicCell<T>, AtomicCellError>
pub fn try_new(value: T) -> Result<AtomicCell<T>, AtomicCellError>
Create a new atomic cell with validation.
§Errors
Returns AtomicCellError::TypeTooLarge if the type is too large.
Trait Implementations§
Source§impl<T> Clone for AtomicCell<T>
impl<T> Clone for AtomicCell<T>
Source§fn clone(&self) -> AtomicCell<T>
fn clone(&self) -> AtomicCell<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for AtomicCell<T>
impl<T> Debug for AtomicCell<T>
Source§impl<T> Default for AtomicCell<T>where
T: Default,
impl<T> Default for AtomicCell<T>where
T: Default,
Source§fn default() -> AtomicCell<T>
fn default() -> AtomicCell<T>
Returns the “default value” for a type. Read more
impl<T> Send for AtomicCell<T>where
T: Send,
impl<T> Sync for AtomicCell<T>where
T: Sync,
Auto Trait Implementations§
impl<T> !Freeze for AtomicCell<T>
impl<T> !RefUnwindSafe for AtomicCell<T>
impl<T> Unpin for AtomicCell<T>where
T: Unpin,
impl<T> UnsafeUnpin for AtomicCell<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for AtomicCell<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more