Skip to main content

StructuralMutator

Trait StructuralMutator 

Source
pub trait StructuralMutator: Sized {
Show 13 methods // Required method fn dispatch_mutate( &mut self, value: &MapValue, def_region_kind: DefRegionKind, ) -> Result<Any>; // Provided methods fn dispatch_maybe_inplace_mutate( &mut self, value: InplaceValue<'_>, def_region_kind: DefRegionKind, ) -> Result<Any> { ... } fn mutate<T>( &mut self, value: &T, def_region_kind: DefRegionKind, ) -> Result<Any> where for<'x> AnyView<'x>: From<&'x T> { ... } fn maybe_inplace_mutate<T>( &mut self, value: T, def_region_kind: DefRegionKind, ) -> Result<Any> where T: Into<Any> { ... } fn default_mutate( &mut self, value: &MapValue, def_region_kind: DefRegionKind, ) -> Result<Any> { ... } fn default_mutate_value<T>( &mut self, value: &T, def_region_kind: DefRegionKind, ) -> Result<Any> where for<'x> AnyView<'x>: From<&'x T> { ... } fn default_maybe_inplace_mutate( &mut self, value: InplaceValue<'_>, def_region_kind: DefRegionKind, ) -> Result<Any> { ... } fn mutate_result<T>( &mut self, value: &T, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>> where for<'x> AnyView<'x>: From<&'x T> { ... } fn default_mutate_result( &mut self, value: &MapValue, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>> { ... } fn default_mutate_value_result<T>( &mut self, value: &T, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>> where for<'x> AnyView<'x>: From<&'x T> { ... } fn default_maybe_inplace_mutate_result( &mut self, value: InplaceValue<'_>, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>> { ... } fn var_remap_get(&mut self, var: &MapValue) -> Result<Option<Any>> { ... } fn var_remap_set( &mut self, var: &MapValue, mutated_value: &Any, ) -> Result<()> { ... }
}
Expand description

A low-level mutator that controls its own recursion.

Implementations descend with the mutate or default_* helpers. Prefer mutation callbacks or #[dispatch(mutate)] for typed dispatch with recursion supplied through Mutator.

Required Methods§

Source

fn dispatch_mutate( &mut self, value: &MapValue, def_region_kind: DefRegionKind, ) -> Result<Any>

Dispatch one borrowed value without modifying its source storage.

The structural-mutation engine calls this hook for each value.

Provided Methods§

Source

fn dispatch_maybe_inplace_mutate( &mut self, value: InplaceValue<'_>, def_region_kind: DefRegionKind, ) -> Result<Any>

Dispatch one value for which the engine permits an in-place attempt.

The default delegates to Self::dispatch_mutate and therefore remains non-in-place. Override this method to opt into the default container reuse path.

Source

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

Re-enter this mutator for a borrowed value. The value and all of its descendants use the non-in-place path.

Source

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

Re-enter this mutator for an owned value, permitting reuse only when the converted value remains uniquely owned.

Source

fn default_mutate( &mut self, value: &MapValue, def_region_kind: DefRegionKind, ) -> Result<Any>

Apply default non-in-place mutation to value’s children.

Source

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

Apply default non-in-place mutation to a borrowed typed value.

Unlike Self::mutate, this bypasses dispatch for the value itself while its children still re-enter this mutator. This lets a typed structural-mutate handler recurse through its current node before applying a post-order rewrite.

Source

fn default_maybe_inplace_mutate( &mut self, value: InplaceValue<'_>, def_region_kind: DefRegionKind, ) -> Result<Any>

Apply the default mutation under an engine-issued in-place capability.

Uniqueness is checked again here because user code may have retained an owning alias after the capability was issued.

Source

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

Re-enter this mutator for a borrowed value, preserving unchanged.

Source

fn default_mutate_result( &mut self, value: &MapValue, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>>

Default non-in-place mutation with an unchanged-or-replacement result.

Source

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

Default mutation of a borrowed typed value, preserving unchanged.

Source

fn default_maybe_inplace_mutate_result( &mut self, value: InplaceValue<'_>, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>>

Default mutation under an engine-issued capability, preserving unchanged.

Source

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

Look up a FreeVar or DAG-node substitution from the active mutation.

Source

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

Store a FreeVar or DAG-node substitution for the active mutation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<D: MutateDispatch> StructuralMutator for D

Source§

impl<State, Link, Marker> StructuralMutator for MutateCallbacks<State, Link, Marker>
where Link: MutateChainLink<State, Marker>, Link::Strategy: MutateCallbackStrategy<State, Link, Marker>,