Write

Struct Write 

Source
#[non_exhaustive]
pub struct Write<T: ?Sized> { /* private fields */ }
Expand description

An (interiorly-)mutable reference inside a GC’d object graph.

This type can only exist behind a reference; it is typically obtained by calling Gc::write on a Gc pointer or by using the field! projection macro on a pre-existing &Write<T>.

Implementations§

Source§

impl<T: ?Sized> Write<T>

Source

pub unsafe fn assume(v: &T) -> &Self

Asserts that the given reference can be safely written to.

§Safety

In order to maintain the invariants of the garbage collector, no new Gc pointers may be adopted by the referenced value as a result of the interior mutability enabled by this wrapper, unless Gc::write is invoked manually on the parent Gc pointer during the current arena callback.

Source

pub fn from_static(v: &T) -> &Self
where T: 'static,

Gets a writable reference to non-GC’d data.

This is safe, as 'static types can never hold Gc pointers.

Source

pub fn from_mut(v: &mut T) -> &mut Self

Gets a writable reference from a &mut T.

This is safe, as exclusive access already implies writability.

Source

pub fn unlock(&self) -> &T::Unlocked
where T: Unlock,

Unlocks the referenced value, providing full interior mutability.

Source§

impl<T> Write<Option<T>>

Source

pub fn as_write(&self) -> Option<&Write<T>>

Converts from &Write<Option<T>> to Option<&Write<T>>.

Source§

impl<T, E> Write<Result<T, E>>

Source

pub fn as_write(&self) -> Result<&Write<T>, &Write<E>>

Converts from &Write<Result<T, E>> to Result<&Write<T>, &Write<E>>.

Trait Implementations§

Source§

impl<T: ?Sized> Deref for Write<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: ?Sized> DerefMut for Write<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<T> Freeze for Write<T>
where T: Freeze + ?Sized,

§

impl<T> RefUnwindSafe for Write<T>
where T: RefUnwindSafe + ?Sized,

§

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

§

impl<T> Sync for Write<T>
where T: Sync + ?Sized,

§

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

§

impl<T> UnwindSafe for Write<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<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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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

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.