[−][src]Struct qcell::LCellOwner
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 that
this code is based on predates the GhostCell
implementation.
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]
F: for<'scope_id> FnOnce(LCellOwner<'scope_id>),
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 cell<T>(&self, value: T) -> LCell<'id, T>
[src]
Create a new cell owned by this owner instance. See also
LCell::new
.
pub fn ro<'a, T>(&'a self, lc: &'a LCell<'id, T>) -> &'a T
[src]
Borrow contents of a LCell
immutably (read-only). Many
LCell
instances can be borrowed immutably at the same time
from the same owner.
pub fn rw<'a, T>(&'a mut self, lc: &'a LCell<'id, T>) -> &'a mut T
[src]
Borrow contents of a LCell
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.
pub fn rw2<'a, T, U>(
&'a mut self,
lc1: &'a LCell<'id, T>,
lc2: &'a LCell<'id, U>
) -> (&'a mut T, &'a mut U)
[src]
&'a mut self,
lc1: &'a LCell<'id, T>,
lc2: &'a LCell<'id, U>
) -> (&'a mut T, &'a mut U)
Borrow contents of two LCell
instances mutably. Panics if
the two LCell
instances point to the same memory.
pub fn rw3<'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]
&'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)
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]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,