Struct lucia_lang::gc::RefCell
source · pub struct RefCell<T: ?Sized> { /* private fields */ }Expand description
A mutable memory location with dynamically checked borrow rules.
Implementations§
source§impl<T: ?Sized> RefCell<T>
impl<T: ?Sized> RefCell<T>
sourcepub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Immutably borrows the wrapped value.
The borrow lasts until the returned Ref exits scope. Multiple
immutable borrows can be taken out at the same time.
Panics
Panics if the value is currently mutably borrowed. For a non-panicking variant, use
try_borrow.
sourcepub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
pub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
Immutably borrows the wrapped value, returning an error if the value is currently mutably borrowed.
The borrow lasts until the returned Ref exits scope. Multiple immutable borrows can be
taken out at the same time.
This is the non-panicking variant of borrow.
sourcepub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
Mutably borrows the wrapped value.
The borrow lasts until the returned RefMut or all RefMuts derived
from it exit scope. The value cannot be borrowed while this borrow is
active.
Panics
Panics if the value is currently borrowed. For a non-panicking variant, use
try_borrow_mut.
sourcepub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
pub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
Mutably borrows the wrapped value, returning an error if the value is currently borrowed.
The borrow lasts until the returned RefMut or all RefMuts derived
from it exit scope. The value cannot be borrowed while this borrow is
active.
This is the non-panicking variant of borrow_mut.
sourcepub fn is_writing(&self) -> bool
pub fn is_writing(&self) -> bool
Returns whether this cell is writing.
sourcepub fn is_reading(&self) -> bool
pub fn is_reading(&self) -> bool
Returns whether this cell is reading.
Trait Implementations§
source§impl<T: ?Sized + PartialOrd> PartialOrd<RefCell<T>> for RefCell<T>
impl<T: ?Sized + PartialOrd> PartialOrd<RefCell<T>> for RefCell<T>
source§fn partial_cmp(&self, other: &RefCell<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &RefCell<T>) -> Option<Ordering>
Panics
Panics if the value in either RefCell is currently borrowed.
source§fn lt(&self, other: &RefCell<T>) -> bool
fn lt(&self, other: &RefCell<T>) -> bool
Panics
Panics if the value in either RefCell is currently borrowed.
source§fn le(&self, other: &RefCell<T>) -> bool
fn le(&self, other: &RefCell<T>) -> bool
Panics
Panics if the value in either RefCell is currently borrowed.
impl<T: ?Sized + Eq> Eq for RefCell<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for RefCell<T>
impl<T: ?Sized> Send for RefCell<T>where T: Send,
impl<T> !Sync for RefCell<T>
impl<T: ?Sized> Unpin for RefCell<T>where T: Unpin,
impl<T: ?Sized> UnwindSafe for RefCell<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.