pub struct TrustCell<T: ?Sized> { /* private fields */ }
Expand description
A custom cell container that is a RefCell
with thread-safety.
Implementations§
source§impl<T> TrustCell<T>
impl<T> TrustCell<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes this cell and returns ownership of T
.
source§impl<T: ?Sized> TrustCell<T>
impl<T: ?Sized> TrustCell<T>
sourcepub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Get an immutable reference to the inner data.
Absence of write accesses is checked at run-time.
§Panics
This function will panic if there is a mutable reference to the data already in use.
sourcepub fn try_borrow(&self) -> Result<Ref<'_, T>, InvalidBorrow>
pub fn try_borrow(&self) -> Result<Ref<'_, T>, InvalidBorrow>
Get an immutable reference to the inner data.
Absence of write accesses is checked at run-time. If access is not possible, an error is returned.
sourcepub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
Get a mutable reference to the inner data.
Exclusive access is checked at run-time.
§Panics
This function will panic if there are any references to the data already in use.
sourcepub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, InvalidBorrow>
pub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, InvalidBorrow>
Get a mutable reference to the inner data.
Exclusive access is checked at run-time. If access is not possible, an error is returned.#
sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Gets exclusive access to the inner value, bypassing the Cell.
Exclusive access is checked at compile time.