Expand description
Before/after diffing into PatchOp lists.
diff walks two versions of a state tree and emits the op set that
reconstructs after from before:
- both sides objects → recurse per key over the union; added/changed
keys yield
setops, removed keys yielddelops; - values differing (at least one side not an object) → a single
setof the new value at the current path; - equal values → no op.
All generated paths are prefixed with prefix (usually state), so the
same trees can be diffed at any sub-root. Roundtrip guarantee:
apply_all(before.clone(), diff(prefix, &before, &after)) == after —
pinned by the property-based test in tests/patch_compat.rs, for the
state-tree domain where object members carry no explicit nulls (the
one RFC 7396 caveat: a null member inside a wholesale-written object
value cannot survive the deep merge; nulls as whole leaf values
roundtrip fine).
Functions§
- diff
- Diffs two versions of a state tree into the op list that transforms
beforeintoafter. See the module docs for the strategy.