pub struct GcRefCell<T: ?Sized + 'static> { /* private fields */ }
Expand description
A mutable memory location with dynamically checked borrow rules that can be used inside of a garbage-collected pointer.
This object is a RefCell
that can be used inside of a Gc<T>
.
Implementations§
source§impl<T: Trace> GcRefCell<T>
impl<T: Trace> GcRefCell<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the GcCell
, returning the wrapped value.
source§impl<T: Trace + ?Sized> GcRefCell<T>
impl<T: Trace + ?Sized> GcRefCell<T>
sourcepub fn borrow(&self) -> GcRef<'_, T>
pub fn borrow(&self) -> GcRef<'_, T>
Immutably borrows the wrapped value.
The borrow lasts until the returned GcCellRef
exits scope.
Multiple immutable borrows can be taken out at the same time.
§Panics
Panics if the value is currently mutably borrowed.
sourcepub fn borrow_mut(&self) -> GcRefMut<'_, T>
pub fn borrow_mut(&self) -> GcRefMut<'_, T>
Mutably borrows the wrapped value.
The borrow lasts until the returned GcCellRefMut
exits scope.
The value cannot be borrowed while this borrow is active.
§Panics
Panics if the value is currently borrowed.
sourcepub fn try_borrow(&self) -> Result<GcRef<'_, T>, BorrowError>
pub fn try_borrow(&self) -> Result<GcRef<'_, T>, BorrowError>
Immutably borrows the wrapped value, returning an error if the value is currently mutably borrowed.
The borrow lasts until the returned GcCellRef
exits scope. Multiple immutable borrows can be
taken out at the same time.
This is the non-panicking variant of borrow
.
§Errors
Returns an Err
if the value is currently mutably borrowed.
sourcepub fn try_borrow_mut(&self) -> Result<GcRefMut<'_, T>, BorrowMutError>
pub fn try_borrow_mut(&self) -> Result<GcRefMut<'_, T>, BorrowMutError>
Mutably borrows the wrapped value, returning an error if the value is currently borrowed.
The borrow lasts until the returned GcCellRefMut
exits scope.
The value cannot be borrowed while this borrow is active.
This is the non-panicking variant of borrow_mut
.
§Errors
Returns an Err
if the value is currently borrowed.
Trait Implementations§
source§impl<T: Trace + ?Sized + PartialEq> PartialEq for GcRefCell<T>
impl<T: Trace + ?Sized + PartialEq> PartialEq for GcRefCell<T>
source§impl<T: Trace + ?Sized + PartialOrd> PartialOrd for GcRefCell<T>
impl<T: Trace + ?Sized + PartialOrd> PartialOrd for GcRefCell<T>
source§impl<T: Trace + ?Sized> Trace for GcRefCell<T>
impl<T: Trace + ?Sized> Trace for GcRefCell<T>
source§unsafe fn trace_non_roots(&self)
unsafe fn trace_non_roots(&self)
source§fn run_finalizer(&self)
fn run_finalizer(&self)
Finalize::finalize
on this object and all
contained subobjects.