pub struct TrustCell<T> { /* 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 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> !Freeze for TrustCell<T>
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§
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
Source§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
Source§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
Tries to create the default.
Source§fn unwrap_default() -> Self
fn unwrap_default() -> Self
Calls
try_default and panics on an error case.