pub struct UnsafeCell<T: ?Sized> { /* private fields */ }
Expand description
A checked version of std::cell::UnsafeCell
.
Instead of providing a get()
API, this version of UnsafeCell
provides
with
and with_mut
. Both functions take a closure in order to track the
start and end of the access to the underlying cell.
Implementations§
Source§impl<T> UnsafeCell<T>
impl<T> UnsafeCell<T>
Sourcepub fn new(data: T) -> UnsafeCell<T>
pub fn new(data: T) -> UnsafeCell<T>
Constructs a new instance of UnsafeCell
which will wrap the specified value.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwraps the value.
Source§impl<T: ?Sized> UnsafeCell<T>
impl<T: ?Sized> UnsafeCell<T>
Sourcepub fn with<F, R>(&self, f: F) -> R
pub fn with<F, R>(&self, f: F) -> R
Get an immutable pointer to the wrapped value.
§Panics
This function will panic if the access is not valid under the Rust memory model.
Sourcepub fn with_mut<F, R>(&self, f: F) -> R
pub fn with_mut<F, R>(&self, f: F) -> R
Get a mutable pointer to the wrapped value.
§Panics
This function will panic if the access is not valid under the Rust memory model.
Sourcepub fn get(&self) -> ConstPtr<T>
pub fn get(&self) -> ConstPtr<T>
Get an immutable pointer to the wrapped value.
This function returns a ConstPtr
guard, which is analogous to a
*const T
, but tracked by Fenic. As long as the returned ConstPtr
exists, Fenic will consider the cell to be accessed immutably.
This means that any mutable accesses (e.g. calls to with_mut
or
get_mut
) while the returned guard is live will result in a panic.
§Panics
This function will panic if the access is not valid under the Rust memory model.
Sourcepub fn get_mut(&self) -> MutPtr<T>
pub fn get_mut(&self) -> MutPtr<T>
Get a mutable pointer to the wrapped value.
This function returns a MutPtr
guard, which is analogous to a
*mut T
, but tracked by Fenic. As long as the returned MutPtr
exists, Fenic will consider the cell to be accessed mutably.
This means that any concurrent mutable or immutable accesses (e.g. calls
to with
, with_mut
, get
, or get_mut
) while the returned
guard is live will result in a panic.
§Panics
This function will panic if the access is not valid under the Rust memory model.