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§
Sourcefn dispatch_mutate(
&mut self,
value: &MapValue,
def_region_kind: DefRegionKind,
) -> Result<Any>
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§
Sourcefn dispatch_maybe_inplace_mutate(
&mut self,
value: InplaceValue<'_>,
def_region_kind: DefRegionKind,
) -> Result<Any>
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.
Sourcefn mutate<T>(
&mut self,
value: &T,
def_region_kind: DefRegionKind,
) -> Result<Any>
fn mutate<T>( &mut self, value: &T, def_region_kind: DefRegionKind, ) -> Result<Any>
Re-enter this mutator for a borrowed value. The value and all of its descendants use the non-in-place path.
Sourcefn maybe_inplace_mutate<T>(
&mut self,
value: T,
def_region_kind: DefRegionKind,
) -> Result<Any>
fn maybe_inplace_mutate<T>( &mut self, value: T, def_region_kind: DefRegionKind, ) -> Result<Any>
Re-enter this mutator for an owned value, permitting reuse only when the converted value remains uniquely owned.
Sourcefn default_mutate(
&mut self,
value: &MapValue,
def_region_kind: DefRegionKind,
) -> Result<Any>
fn default_mutate( &mut self, value: &MapValue, def_region_kind: DefRegionKind, ) -> Result<Any>
Apply default non-in-place mutation to value’s children.
Sourcefn default_mutate_value<T>(
&mut self,
value: &T,
def_region_kind: DefRegionKind,
) -> Result<Any>
fn default_mutate_value<T>( &mut self, value: &T, def_region_kind: DefRegionKind, ) -> Result<Any>
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.
Sourcefn default_maybe_inplace_mutate(
&mut self,
value: InplaceValue<'_>,
def_region_kind: DefRegionKind,
) -> Result<Any>
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.
Sourcefn mutate_result<T>(
&mut self,
value: &T,
kind: DefRegionKind,
) -> Result<UnchangedOr<Any>>
fn mutate_result<T>( &mut self, value: &T, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>>
Re-enter this mutator for a borrowed value, preserving unchanged.
Sourcefn default_mutate_result(
&mut self,
value: &MapValue,
kind: DefRegionKind,
) -> Result<UnchangedOr<Any>>
fn default_mutate_result( &mut self, value: &MapValue, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>>
Default non-in-place mutation with an unchanged-or-replacement result.
Sourcefn default_mutate_value_result<T>(
&mut self,
value: &T,
kind: DefRegionKind,
) -> Result<UnchangedOr<Any>>
fn default_mutate_value_result<T>( &mut self, value: &T, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>>
Default mutation of a borrowed typed value, preserving unchanged.
Sourcefn default_maybe_inplace_mutate_result(
&mut self,
value: InplaceValue<'_>,
kind: DefRegionKind,
) -> Result<UnchangedOr<Any>>
fn default_maybe_inplace_mutate_result( &mut self, value: InplaceValue<'_>, kind: DefRegionKind, ) -> Result<UnchangedOr<Any>>
Default mutation under an engine-issued capability, preserving unchanged.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".