Struct gc::GcCell [−][src]
pub struct GcCell<T: ?Sized + 'static> { /* fields omitted */ }
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
impl<T: Trace> GcCell<T>
[src]
impl<T: Trace> GcCell<T>
[src]pub fn into_inner(self) -> T
[src]
pub fn into_inner(self) -> T
[src]Consumes the GcCell
, returning the wrapped value.
impl<T: Trace + ?Sized> GcCell<T>
[src]
impl<T: Trace + ?Sized> GcCell<T>
[src]pub fn borrow(&self) -> GcCellRef<'_, T>
[src]
pub fn borrow(&self) -> GcCellRef<'_, T>
[src]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.
pub fn borrow_mut(&self) -> GcCellRefMut<'_, T>
[src]
pub fn borrow_mut(&self) -> GcCellRefMut<'_, T>
[src]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.
pub fn try_borrow(&self) -> Result<GcCellRef<'_, T>, BorrowError>
[src]
pub fn try_borrow(&self) -> Result<GcCellRef<'_, T>, BorrowError>
[src]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
.
Examples
use gc::GcCell; let c = GcCell::new(5); { let m = c.borrow_mut(); assert!(c.try_borrow().is_err()); } { let m = c.borrow(); assert!(c.try_borrow().is_ok()); }
pub fn try_borrow_mut(&self) -> Result<GcCellRefMut<'_, T>, BorrowMutError>
[src]
pub fn try_borrow_mut(&self) -> Result<GcCellRefMut<'_, T>, BorrowMutError>
[src]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
.
Examples
use gc::GcCell; let c = GcCell::new(5); { let m = c.borrow(); assert!(c.try_borrow_mut().is_err()); } assert!(c.try_borrow_mut().is_ok());
Trait Implementations
impl<T: Trace + ?Sized + Ord> Ord for GcCell<T>
[src]
impl<T: Trace + ?Sized + Ord> Ord for GcCell<T>
[src]impl<T: Trace + ?Sized + PartialOrd> PartialOrd<GcCell<T>> for GcCell<T>
[src]
impl<T: Trace + ?Sized + PartialOrd> PartialOrd<GcCell<T>> for GcCell<T>
[src]fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Self) -> bool
[src]
fn lt(&self, other: &Self) -> bool
[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Trace + ?Sized> Trace for GcCell<T>
[src]
impl<T: Trace + ?Sized> Trace for GcCell<T>
[src]fn finalize_glue(&self)
[src]
fn finalize_glue(&self)
[src]Runs Finalize::finalize() on this object and all contained subobjects Read more
impl<T: Trace + ?Sized + Eq> Eq for GcCell<T>
[src]
impl<T: ?Sized + Send> Send for GcCell<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for GcCell<T>
impl<T> !Sync for GcCell<T>
impl<T: ?Sized> Unpin for GcCell<T> where
T: Unpin,
T: Unpin,
impl<T: ?Sized> UnwindSafe for GcCell<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more