Struct gc_arena::lock::RefLock

source ·
pub struct RefLock<T: ?Sized> { /* private fields */ }
Expand description

A wrapper around a RefCell that implements Collect.

Only provides safe read access to the wrapped RefCell, full write access requires unsafety.

If the RefLock is directly held in a Gc pointer, safe mutable access is provided, since methods on Gc can ensure that the write barrier is called.

Implementations§

source§

impl<T> RefLock<T>

source

pub fn new(t: T) -> RefLock<T>

source

pub fn into_inner(self) -> T

source

pub fn take(&self) -> T
where T: Default,

source§

impl<T: ?Sized> RefLock<T>

source

pub fn as_ptr(&self) -> *mut T

source

pub fn borrow<'a>(&'a self) -> Ref<'a, T>

source

pub fn try_borrow<'a>(&'a self) -> Result<Ref<'a, T>, BorrowError>

source

pub unsafe fn as_ref_cell(&self) -> &RefCell<T>

Access the wrapped RefCell.

§Safety

In order to maintain the invariants of the garbage collector, no new Gc pointers may be adopted by this type as a result of the interior mutability afforded by directly accessing the inner RefCell, unless the write barrier for the containing Gc pointer is invoked manuall before collection is triggered.

source

pub fn get_mut(&mut self) -> &mut T

Trait Implementations§

source§

impl<T: Clone + ?Sized> Clone for RefLock<T>

source§

fn clone(&self) -> RefLock<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'gc, T: Collect + 'gc> Collect for RefLock<T>

source§

fn needs_trace() -> bool

As an optimization, if this type can never hold a Gc pointer and trace is unnecessary to call, you may implement this method and return false. The default implementation returns true, signaling that Collect::trace must be called.
source§

fn trace(&self, cc: &Collection)

Must call Collect::trace on all held Gc pointers. If this type holds inner types that implement Collect, a valid implementation would simply call Collect::trace on all the held values to ensure this.
source§

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

source§

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

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

impl<T: Default + ?Sized> Default for RefLock<T>

source§

fn default() -> RefLock<T>

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

impl<T> From<RefCell<T>> for RefLock<T>

source§

fn from(cell: RefCell<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<T> for RefLock<T>

source§

fn from(t: T) -> Self

Converts to this type from the input type.
source§

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

source§

fn cmp(&self, other: &RefLock<T>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

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

source§

fn eq(&self, other: &RefLock<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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

source§

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

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

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: ?Sized> Unlock for RefLock<T>

§

type Unlocked = RefCell<T>

This will typically be a cell-like type providing some sort of interior mutability.
source§

unsafe fn unlock_unchecked(&self) -> &Self::Unlocked

Provides unsafe access to the unlocked type, without triggering a write barrier. Read more
source§

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

source§

impl<T: ?Sized> StructuralPartialEq for RefLock<T>

Auto Trait Implementations§

§

impl<T> !Freeze for RefLock<T>

§

impl<T> !RefUnwindSafe for RefLock<T>

§

impl<T> Send for RefLock<T>
where T: Send + ?Sized,

§

impl<T> !Sync for RefLock<T>

§

impl<T> Unpin for RefLock<T>
where T: Unpin + ?Sized,

§

impl<T> UnwindSafe for RefLock<T>
where T: UnwindSafe + ?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> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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> ToOwned for T
where T: Clone,

§

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>,

§

type Error = Infallible

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>,

§

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.