pub trait UnsafeCellExt<T> {
// Required methods
unsafe fn as_mut(&self) -> &mut T;
fn replace(&self, _: T) -> T;
}
Required Methods§
Implementations on Foreign Types§
Source§impl<T> UnsafeCellExt<T> for UnsafeCell<T>
impl<T> UnsafeCellExt<T> for UnsafeCell<T>
Source§unsafe fn as_mut(&self) -> &mut T
unsafe fn as_mut(&self) -> &mut T
Returns a mutable reference to the underlying data contained within an unsafe cell. This function is marked as unsafe because it directly casts the internal pointer to a mutable reference, thereby bypassing Rust’s normal borrowing rules.
Source§fn replace(&self, v: T) -> T
fn replace(&self, v: T) -> T
Replaces the value contained within an internal cell with a new value while returning the previous content.
This function consumes a new value to update the internal state and returns the original value that was stored, effectively performing an atomic swap operation in the cell’s memory.