pub struct Cell<T> { /* private fields */ }
Expand description
A custom cell container that is a RefCell
with thread-safety.
Implementations
sourceimpl<T> Cell<T>
impl<T> Cell<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) -> CellRef<'_, T>
pub fn borrow(&self) -> CellRef<'_, 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<CellRef<'_, T>, BorrowFail>
pub fn try_borrow(&self) -> Result<CellRef<'_, T>, BorrowFail>
Get an immutable reference to the inner data.
Absence of write accesses is checked at run-time. If access is not
possible, None
is returned.
sourcepub fn borrow_mut(&self) -> CellRefMut<'_, T>
pub fn borrow_mut(&self) -> CellRefMut<'_, 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<CellRefMut<'_, T>, BorrowFail>
pub fn try_borrow_mut(&self) -> Result<CellRefMut<'_, T>, BorrowFail>
Get a mutable reference to the inner data.
Exclusive access is checked at run-time. If access is not possible,
None
is returned.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Cell<T>
impl<T> Send for Cell<T> where
T: Send,
impl<T> Unpin for Cell<T> where
T: Unpin,
impl<T> UnwindSafe for Cell<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