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 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§
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.