Skip to main content

MutateContext

Struct MutateContext 

Source
pub struct MutateContext<'a, State, Driver: ?Sized = dyn MutateContextDriver<State> + 'a> { /* private fields */ }
Expand description

State and recursive operations available to a callback-chain mutation.

A matched callback owns mutation of its value. Recursive operations reborrow the mutator, so mutable state cannot remain borrowed across them.

Implementations§

Source§

impl<State, Driver> MutateContext<'_, State, Driver>
where Driver: MutateContextDriver<State> + ?Sized,

Source

pub fn state(&self) -> &State

User state shared by every callback in this mutation.

Source

pub fn state_mut(&mut self) -> &mut State

Mutably borrow the user state.

Source

pub fn current(&self) -> &MapValue

Complete borrowed value active at this callback.

Source

pub fn def_region_kind(&self) -> DefRegionKind

Definition-region state active at the callback’s current value.

Source

pub fn region(&self) -> DefRegionKind

Definition region active at the callback’s current value.

Source

pub fn mutate<T>(&mut self, value: &T) -> Result<Any>
where for<'x> AnyView<'x>: From<&'x T>,

Mutate a borrowed value through the same callback chain. The value and its descendants begin on the non-in-place path.

Source

pub fn mutate_with<T>( &mut self, value: &T, def_region_kind: DefRegionKind, ) -> Result<Any>
where for<'x> AnyView<'x>: From<&'x T>,

Mutate a borrowed value under an explicit definition-region state.

Source

pub fn maybe_inplace_mutate<T: Into<Any>>(&mut self, value: T) -> Result<Any>

Mutate an owned value, allowing an in-place attempt when it remains uniquely owned and no matched callback borrows it.

Source

pub fn maybe_inplace_mutate_with<T: Into<Any>>( &mut self, value: T, def_region_kind: DefRegionKind, ) -> Result<Any>

Mutate an owned value under an explicit definition-region state.

Source

pub fn default_mutate(&mut self) -> Result<Any>

Apply default mutation to the callback’s current value.

This operation always uses the copy path because a callback may still hold a shared borrow of the current value. It may be called repeatedly.

Source

pub fn mutate_result<T>(&mut self, value: &T) -> Result<UnchangedOr<Any>>
where for<'x> AnyView<'x>: From<&'x T>,

Mutate a borrowed child while preserving an unchanged result.

Source

pub fn mutate_with_result<T>( &mut self, value: &T, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>>
where for<'x> AnyView<'x>: From<&'x T>,

Mutate a borrowed child under an explicit region, preserving unchanged.

Source

pub fn default_mutate_result(&mut self) -> Result<UnchangedOr<Any>>

Apply default mutation without materializing an unchanged original.

Source

pub fn var_remap_get(&mut self, var: &MapValue) -> Result<Option<Any>>

Look up an invocation-local identity substitution.

Source

pub fn var_remap_set( &mut self, var: &MapValue, mutated_value: &Any, ) -> Result<()>

Store an invocation-local identity substitution.

Auto Trait Implementations§

§

impl<'a, State, Driver = dyn MutateContextDriver<State> + 'a> !Send for MutateContext<'a, State, Driver>

§

impl<'a, State, Driver = dyn MutateContextDriver<State> + 'a> !Sync for MutateContext<'a, State, Driver>

§

impl<'a, State, Driver = dyn MutateContextDriver<State> + 'a> !UnwindSafe for MutateContext<'a, State, Driver>

§

impl<'a, State, Driver> Freeze for MutateContext<'a, State, Driver>
where Driver: ?Sized,

§

impl<'a, State, Driver> RefUnwindSafe for MutateContext<'a, State, Driver>
where Driver: RefUnwindSafe + ?Sized,

§

impl<'a, State, Driver> Unpin for MutateContext<'a, State, Driver>
where Driver: ?Sized,

§

impl<'a, State, Driver> UnsafeUnpin for MutateContext<'a, State, Driver>
where Driver: ?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.