pub trait StructuralMutator: Sized {
Show 14 methods
// Required method
fn dispatch_mutate(
&mut self,
value: &StructuralView,
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 maybe_inplace_mutate_with_mode<T>(
&mut self,
value: T,
def_region_kind: DefRegionKind,
mode: InplaceMode,
) -> Result<Any>
where T: Into<Any> { ... }
fn default_mutate<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 default_maybe_inplace_mutate_with_mode(
&mut self,
value: InplaceValue<'_>,
def_region_kind: DefRegionKind,
mode: InplaceMode,
) -> 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<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 default_maybe_inplace_mutate_with_mode_result(
&mut self,
value: InplaceValue<'_>,
kind: DefRegionKind,
mode: InplaceMode,
) -> Result<UnchangedOr<Any>> { ... }
fn var_remap_get(&mut self, var: &StructuralView) -> Result<Option<Any>> { ... }
fn var_remap_set(
&mut self,
var: &StructuralView,
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: &StructuralView,
def_region_kind: DefRegionKind,
) -> Result<Any>
fn dispatch_mutate( &mut self, value: &StructuralView, 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 maybe_inplace_mutate_with_mode<T>(
&mut self,
value: T,
def_region_kind: DefRegionKind,
mode: InplaceMode,
) -> Result<Any>
fn maybe_inplace_mutate_with_mode<T>( &mut self, value: T, def_region_kind: DefRegionKind, mode: InplaceMode, ) -> Result<Any>
Re-enter for an owned value with an explicit region and in-place permission.
Allow checks uniqueness before dispatch; Disallow uses ordinary
mutation without checking uniqueness. An independently owned replacement
or a later explicit owned entry can establish a new permission boundary.
Sourcefn default_mutate<T>(
&mut self,
value: &T,
def_region_kind: DefRegionKind,
) -> Result<Any>
fn default_mutate<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 default_maybe_inplace_mutate_with_mode(
&mut self,
value: InplaceValue<'_>,
def_region_kind: DefRegionKind,
mode: InplaceMode,
) -> Result<Any>
fn default_maybe_inplace_mutate_with_mode( &mut self, value: InplaceValue<'_>, def_region_kind: DefRegionKind, mode: InplaceMode, ) -> Result<Any>
Apply default mutation with a capability and an explicit permission.
Disallow overrides the capability and uses the copy path. Allow
rechecks uniqueness because the handler may have retained an owning
alias. Consuming the capability prevents a borrow from it surviving this
call. Unlike the C++ default-descent API, safe Rust cannot simply trust
the earlier uniqueness check after arbitrary user code has run.
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<T>(
&mut self,
value: &T,
kind: DefRegionKind,
) -> Result<UnchangedOr<Any>>
fn default_mutate_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.
Sourcefn default_maybe_inplace_mutate_with_mode_result(
&mut self,
value: InplaceValue<'_>,
kind: DefRegionKind,
mode: InplaceMode,
) -> Result<UnchangedOr<Any>>
fn default_maybe_inplace_mutate_with_mode_result( &mut self, value: InplaceValue<'_>, kind: DefRegionKind, mode: InplaceMode, ) -> Result<UnchangedOr<Any>>
Default mutation with a capability and permission, preserving unchanged.
Uses the same ownership checks as Self::default_maybe_inplace_mutate_with_mode.
Sourcefn var_remap_get(&mut self, var: &StructuralView) -> Result<Option<Any>>
fn var_remap_get(&mut self, var: &StructuralView) -> Result<Option<Any>>
Look up a FreeVar or DAG-node substitution from the active mutation.
Sourcefn var_remap_set(
&mut self,
var: &StructuralView,
mutated_value: &Any,
) -> Result<()>
fn var_remap_set( &mut self, var: &StructuralView, 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".