[][src]Struct qcell::LCellOwner

pub struct LCellOwner<'id> { /* fields omitted */ }

Borrowing-owner of zero or more LCell instances. Use LCellOwner::scope(|owner| ...) to create an instance of this type.

This based around creating an invariant lifetime within the closure, which is different to any other Rust lifetime thanks to the techniques explained in 2015 in this Reddit post, and this Rust playground example. Also see this Reddit comment and its linked playground code.

This works in a similar way to a cell type known as GhostCell or ghost_cell, but the invariant lifetime discussion above predates the GhostCell implementation. Also GhostCell doesn't require an owner to be passed to the cell constructor, instead leaving it to Rust to work out. LCell follows the pattern of the other cell types in this crate, and requires the owner argument which keeps things clear and gives an additional check.

See also crate documentation.

Methods

impl<'id> LCellOwner<'id>[src]

pub fn scope<F>(f: F) where
    F: for<'scope_id> FnOnce(LCellOwner<'scope_id>), 
[src]

Create a new LCellOwner, with a new lifetime, that exists only within the scope of the execution of the given closure call. If two scope calls are nested, then the two owners get different lifetimes.

pub fn get<'a, T>(&'a self, lc: &'a LCell<'id, T>) -> &'a T[src]

Borrow contents of a LCell immutably. Many LCell instances can be borrowed immutably at the same time from the same owner.

pub fn get_mut<'a, T>(&'a mut self, lc: &'a LCell<'id, T>) -> &'a mut T[src]

Borrow contents of a LCell mutably. 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.

pub fn get_mut2<'a, T, U>(
    &'a mut self,
    lc1: &'a LCell<'id, T>,
    lc2: &'a LCell<'id, U>
) -> (&'a mut T, &'a mut U)
[src]

Borrow contents of two LCell instances mutably. Panics if the two LCell instances point to the same memory.

pub fn get_mut3<'a, T, U, V>(
    &'a mut self,
    lc1: &'a LCell<'id, T>,
    lc2: &'a LCell<'id, U>,
    lc3: &'a LCell<'id, V>
) -> (&'a mut T, &'a mut U, &'a mut V)
[src]

Borrow contents of three LCell instances mutably. Panics if any pair of LCell instances point to the same memory.

Auto Trait Implementations

impl<'id> Send for LCellOwner<'id>

impl<'id> !Sync for LCellOwner<'id>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]