pub fn structural_walk<'input, R, M, H>(
root: R,
walker: H,
order: WalkOrder,
) -> Result<Option<VisitInterrupt>>Expand description
Walk root with an observer, the Rust analog of C++
StructuralWalk<order>(root, callbacks...).
walker is anything implementing IntoWalker: a &mut reference to a
stateful Dispatcher walker (#[dispatch(walk)]), a bare closure
in any WalkChainLink shape (catch-all AnyView<'_>, typed, or node,
with an optional trailing DefRegionKind), or a tuple of such
callbacks tried in order — the C++ callback overloads and variadic
chain.
Callback views cannot escape their invocation; retain an Any explicitly
when a value must outlive the callback:
ⓘ
use tvm_ffi::{structural_walk, AnyView, WalkOrder, WalkResult};
let mut retained: Option<AnyView<'static>> = None;
structural_walk(&1_i64, |value: AnyView<'_>| {
retained = Some(value);
WalkResult::Advance
}, WalkOrder::PreOrder).unwrap();The walker owns recursion: the handler runs once per value,
before or after the value’s children according to order, and steers
traversal through the returned WalkResult.