Skip to main content

structural_map

Function structural_map 

Source
pub fn structural_map<R, M, H>(
    root: R,
    mapper: H,
    order: WalkOrder,
) -> Result<Any>
where R: Into<Any>, H: IntoMapper<M>,
Expand description

Transform a structured value graph with ordered replacement callbacks.

The root is consumed. A uniquely owned built-in container may therefore be reused in place, while passing root.clone() keeps the original shared and selects copy-on-write behavior. Map and Dict keys are anchors and are not mapped. Their registered structural hooks own container traversal.

Callbacks run at every occurrence. Default reflected descent handles FreeVar and DAG-node remapping; registered hooks own their type’s remapping policy. Callback replacements are not automatically recorded as substitutions.

In-place changes completed before an error are not rolled back. Because this function consumes root, an error does not return the partly mapped root to the caller.