Write

Struct Write 

Source
pub struct Write<T: ?Sized>(/* private fields */);
Expand description

A marker type which indicates that any owning Gc has been marked as having been modified.

Implementations§

Source§

impl<T: ?Sized> Write<T>

Source

pub unsafe fn new_unchecked(value: &T) -> &Write<T>

§Safety

The parent Gc must have been marked as mutated.

Source

pub fn new_static(value: &T) -> &Write<T>
where T: 'static,

Source

pub fn into_inner(&self) -> &T

Source

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

Source

pub fn project<U: ?Sized>( &self, f: impl for<'a> FnOnce(&'a T) -> &'a U, ) -> &Write<U>

Projects a write permission into a write permision of the of the values contained by self.

§Panics

When the closure returns a reference to a value not contained within the bounds of self.

Source

pub fn try_project<U: ?Sized>( &self, f: impl for<'a> FnOnce(&'a T) -> &'a U, ) -> Result<&Write<U>, WriteProjectError>

Projects a write permission into a write permision of the of the values contained by self, returning an error if the closure returns a reference to a value not contained within the bounds of self.

Source

pub unsafe fn project_unchecked<U: ?Sized>( &self, f: impl for<'a> FnOnce(&'a T) -> &'a U, ) -> &Write<U>

Projects a write permission into a write permission of one of the containing objects fields.

§Safety

The given closure must return a reference to a value which is owned by self. The closure must not dereference a Gc, or in any way project into a value which is owned by another garbage collected pointer, and which could itself contain a garbage collected pointer.

§Examples
#[derive(Debug)]
struct LinkedList<'b, T> {
    data: T,
    next: LockedCell<Option<Gc<'b, Self>>>,
}

let head = Gc::new(LinkedList::<'_, u32> {
    data: 0,
    next: LockedCell::new(Some(Gc::new(LinkedList {
        data: 1,
        next: LockedCell::new(None)
    }, mt)))
}, mt);

unsafe {
    head.write().project_unchecked(|x| &x.data);
    head.write().project_unchecked(|x| &x.next);
}

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