Skip to main content

GcRefCell

Struct GcRefCell 

Source
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> GcRefCell<T>

Source

pub const fn new(value: T) -> Self

Creates a new GcCell containing value.

Source

pub fn into_inner(self) -> T

Consumes the GcCell, returning the wrapped value.

Source§

impl<T: ?Sized> GcRefCell<T>

Source

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.

Source

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.

Source

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.

Source

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 + Clone> Clone for GcRefCell<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ?Sized + Debug> Debug for GcRefCell<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for GcRefCell<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: ?Sized + Eq> Eq for GcRefCell<T>

Source§

impl<T: Trace + ?Sized> Finalize for GcRefCell<T>

Source§

fn finalize(&self)

Cleanup logic for a type.
Source§

impl<T: ?Sized + Ord> Ord for GcRefCell<T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: ?Sized + PartialEq> PartialEq for GcRefCell<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: ?Sized + PartialOrd> PartialOrd for GcRefCell<T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, other: &Self) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
Source§

fn le(&self, other: &Self) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
Source§

fn gt(&self, other: &Self) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
Source§

fn ge(&self, other: &Self) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: ?Sized + Send> Send for GcRefCell<T>

Source§

impl<T: Trace + ?Sized> Trace for GcRefCell<T>

Source§

unsafe fn trace(&self, tracer: &mut Tracer)

Marks all contained Gcs. Read more
Source§

unsafe fn trace_non_roots(&self)

Trace handles located in GC heap, and mark them as non root. Read more
Source§

fn run_finalizer(&self)

Runs Finalize::finalize on this object and all contained subobjects.

Auto Trait Implementations§

§

impl<T> !Freeze for GcRefCell<T>

§

impl<T> !RefUnwindSafe for GcRefCell<T>

§

impl<T> !Sync for GcRefCell<T>

§

impl<T> Unpin for GcRefCell<T>
where UnsafeCell<T>: Unpin, T: ?Sized,

§

impl<T> UnsafeUnpin for GcRefCell<T>
where UnsafeCell<T>: UnsafeUnpin, T: ?Sized,

§

impl<T> UnwindSafe for GcRefCell<T>
where UnsafeCell<T>: UnwindSafe, T: ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.