qcell

Struct TLCell

Source
pub struct TLCell<Q, T: ?Sized> { /* private fields */ }
Expand description

Cell whose contents is owned (for borrowing purposes) by a TLCellOwner.

To borrow from this cell, use the borrowing calls on the TLCellOwner instance that shares the same marker type. Since there may be another indistinguishable TLCellOwner in another thread, Sync is not supported for this type. However it is possible to send the cell to another thread, which then allows its contents to be borrowed using the owner in that thread.

See also crate documentation.

Implementations§

Source§

impl<Q, T> TLCell<Q, T>

Source

pub const fn new(value: T) -> TLCell<Q, T>

Create a new TLCell owned for borrowing purposes by the TLCellOwner derived from the same marker type Q.

Source

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> TLCell<Q, T>

Source

pub fn ro<'a>(&'a self, owner: &'a TLCellOwner<Q>) -> &'a T

Borrow contents of this cell immutably (read-only). Many TLCell instances can be borrowed immutably at the same time from the same owner.

Source

pub fn rw<'a>(&'a self, owner: &'a mut TLCellOwner<Q>) -> &'a mut T

Borrow contents of this cell mutably (read-write). Only one TLCell 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 TLCellOwner::rw2 or TLCellOwner::rw3.

Source

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 TLCell::rw or TLCellOwner::rw to get a mutable reference to the contents of the cell.

Safety: This call borrows TLCell 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.

Trait Implementations§

Source§

impl<Q: 'static, T: Default + ?Sized> Default for TLCell<Q, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Q, T> !Freeze for TLCell<Q, T>

§

impl<Q, T> !RefUnwindSafe for TLCell<Q, T>

§

impl<Q, T> Send for TLCell<Q, T>
where T: Send + ?Sized,

§

impl<Q, T> !Sync for TLCell<Q, T>

§

impl<Q, T> Unpin for TLCell<Q, T>
where T: Unpin + ?Sized,

§

impl<Q, T> UnwindSafe for TLCell<Q, T>
where T: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.