pub struct TrustCell<T> { /* private fields */ }
Expand description
A custom cell container that is a RefCell
with thread-safety.
Implementations
sourceimpl<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
.
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.
Trait Implementations
impl<T> Sync for TrustCell<T> where
T: Sync,
Auto Trait Implementations
impl<T> !RefUnwindSafe for TrustCell<T>
impl<T> Send for TrustCell<T> where
T: Send,
impl<T> Unpin for TrustCell<T> where
T: Unpin,
impl<T> UnwindSafe for TrustCell<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more