Struct qcell::LCell

source ·
#[repr(transparent)]
pub struct LCell<'id, T: ?Sized> { /* private fields */ }
Expand description

Cell whose contents are owned (for borrowing purposes) by a LCellOwner.

To borrow from this cell, use the borrowing calls on the LCellOwner instance that owns it, i.e. that shares the same Rust lifetime.

See also crate documentation.

Implementations§

source§

impl<'id, T> LCell<'id, T>

source

pub fn new(value: T) -> LCell<'id, T>

Create a new LCell. The owner of this cell is inferred by Rust from the context. So the owner lifetime is whatever lifetime is required by the first use of the new LCell.

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<'id, T: ?Sized> LCell<'id, T>

source

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

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

source

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

Borrow contents of this cell mutably (read-write). Only one LCell 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 LCellOwner::rw2 or LCellOwner::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 LCell::rw or LCellOwner::rw to get a mutable reference to the contents of the cell.

Safety: This call borrows LCell 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<'id, T: Default + ?Sized> Default for LCell<'id, T>

source§

fn default() -> Self

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

impl<'id, T: Send + Sync + ?Sized> Sync for LCell<'id, T>

Auto Trait Implementations§

§

impl<'id, T> !RefUnwindSafe for LCell<'id, T>

§

impl<'id, T: ?Sized> Send for LCell<'id, T>where T: Send,

§

impl<'id, T: ?Sized> Unpin for LCell<'id, T>where T: Unpin,

§

impl<'id, T: ?Sized> UnwindSafe for LCell<'id, T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.