pub struct TCell<Q, T: ?Sized> { /* private fields */ }
Expand description
Cell whose contents is owned (for borrowing purposes) by a
TCellOwner
.
To borrow from this cell, use the borrowing calls on the
TCellOwner
instance that shares the same marker type.
See also crate documentation.
Implementations§
Source§impl<Q, T> TCell<Q, T>
impl<Q, T> TCell<Q, T>
Sourcepub const fn new(value: T) -> TCell<Q, T>
pub const fn new(value: T) -> TCell<Q, T>
Create a new TCell
owned for borrowing purposes by the
TCellOwner
derived from the same marker type Q
.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Destroy the cell and return the contained value
Safety: Since this consumes the cell, there can be no other references to the cell or the data at this point.
Source§impl<Q, T: ?Sized> TCell<Q, T>
impl<Q, T: ?Sized> TCell<Q, T>
Sourcepub fn ro<'a>(&'a self, owner: &'a TCellOwner<Q>) -> &'a T
pub fn ro<'a>(&'a self, owner: &'a TCellOwner<Q>) -> &'a T
Borrow contents of this cell immutably (read-only). Many
TCell
instances can be borrowed immutably at the same time
from the same owner.
Sourcepub fn rw<'a>(&'a self, owner: &'a mut TCellOwner<Q>) -> &'a mut T
pub fn rw<'a>(&'a self, owner: &'a mut TCellOwner<Q>) -> &'a mut T
Borrow contents of this cell mutably (read-write). Only one
TCell
at a time can be borrowed from the owner using this
call. The returned reference must go out of scope before
another can be borrowed. To mutably borrow from two or three
cells at the same time, see TCellOwner::rw2
or
TCellOwner::rw3
.
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Returns a mutable reference to the underlying data
Note that this is only useful at the beginning-of-life or
end-of-life of the cell when you have exclusive access to it.
Normally you’d use TCell::rw
or TCellOwner::rw
to get
a mutable reference to the contents of the cell.
Safety: This call borrows TCell
mutably which guarantees
that we possess the only reference. This means that there can
be no active borrows of other forms, even ones obtained using
an immutable reference.