[Feat][Rust] Add native structural_map and structural_mutate - #704
Draft
tlopex wants to merge 6 commits into
Draft
[Feat][Rust] Add native structural_map and structural_mutate#704tlopex wants to merge 6 commits into
tlopex wants to merge 6 commits into
Conversation
Signed-off-by: tlopex <820958424@qq.com>
Signed-off-by: tlopex <820958424@qq.com>
Signed-off-by: tlopex <820958424@qq.com>
Signed-off-by: tlopex <820958424@qq.com>
tlopex
marked this pull request as draft
August 7, 2026 06:27
Signed-off-by: tlopex <820958424@qq.com>
Signed-off-by: tlopex <820958424@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds Rust-native structural transformation support, building on the Rust
structural_visitandstructural_walkinfrastructure introduced in #693.The transformation engine is implemented in Rust.
It provides:
structural_mapwith pre-order and post-order callbacks.StructuralMutatorAPI for user-controlled recursion.#[dispatch(map)].Map and Dict keys remain structural anchors and are not mapped.
Ownership and mutation semantics
The root is consumed so Rust ownership and the runtime strong-reference count define whether a container may be reused.
root.clone(), selects copy-on-write behavior.Foreign
__s_mutate__hooks are rejected rather than silently replacing custom runtime semantics. Types with custom mutation behavior can explicitly take over through the RustStructuralMutatorAPI.Runtime support
This PR adds minimal runtime support for shallow-copying Map and Dict storage.
The runtime helpers preserve:
No object layout or existing C ABI is changed.
The helpers are optional from the Rust crate's perspective. When linked against an older runtime, Rust falls back to the canonical Map/Dict constructors and re-hashes the entries.