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,
impl<State, Driver> MutateContext<'_, State, Driver>where
Driver: MutateContextDriver<State> + ?Sized,
Sourcepub fn state_mut(&mut self) -> &mut State
pub fn state_mut(&mut self) -> &mut State
Mutably borrow the user state.
Sourcepub fn def_region_kind(&self) -> DefRegionKind
pub fn def_region_kind(&self) -> DefRegionKind
Definition-region state active at the callback’s current value.
Sourcepub fn region(&self) -> DefRegionKind
pub fn region(&self) -> DefRegionKind
Definition region active at the callback’s current value.
Sourcepub fn mutate<T>(&mut self, value: &T) -> Result<Any>
pub fn mutate<T>(&mut self, value: &T) -> Result<Any>
Mutate a borrowed value through the same callback chain. The value and its descendants begin on the non-in-place path.
Sourcepub fn mutate_with<T>(
&mut self,
value: &T,
def_region_kind: DefRegionKind,
) -> Result<Any>
pub fn mutate_with<T>( &mut self, value: &T, def_region_kind: DefRegionKind, ) -> Result<Any>
Mutate a borrowed value under an explicit definition-region state.
Sourcepub fn maybe_inplace_mutate<T: Into<Any>>(&mut self, value: T) -> Result<Any>
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.
Sourcepub fn maybe_inplace_mutate_with<T: Into<Any>>(
&mut self,
value: T,
def_region_kind: DefRegionKind,
) -> Result<Any>
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.
Sourcepub fn default_mutate(&mut self) -> Result<Any>
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.
Sourcepub fn mutate_result<T>(&mut self, value: &T) -> Result<UnchangedOr<Any>>
pub fn mutate_result<T>(&mut self, value: &T) -> Result<UnchangedOr<Any>>
Mutate a borrowed child while preserving an unchanged result.
Sourcepub fn mutate_with_result<T>(
&mut self,
value: &T,
kind: DefRegionKind,
) -> Result<UnchangedOr<Any>>
pub fn mutate_with_result<T>( &mut self, value: &T, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>>
Mutate a borrowed child under an explicit region, preserving unchanged.
Sourcepub fn default_mutate_result(&mut self) -> Result<UnchangedOr<Any>>
pub fn default_mutate_result(&mut self) -> Result<UnchangedOr<Any>>
Apply default mutation without materializing an unchanged original.