pub fn diff<'a>(
before: Option<&'a Value>,
after: Option<&'a Value>,
) -> Vec<OwnedChange<'a>>Expand description
Computes the complete diff between before and after.
Walks both values together, path by path. An object’s keys are the union
of both sides’; an array is walked by index up to the longer side’s
length. A path recurses only while both sides at that path are “an object
or absent” (respectively “an array or absent”); anywhere the two sides
disagree in kind — a scalar replacing an object, an array replacing a
scalar, one side absent and the other a leaf — the whole value at that
path becomes one OwnedChange, because there is no shared substructure
left to walk into. An empty object or array on one side, absent on the
other, is reported as a single change at its own path rather than as zero
changes over zero children — the container itself is the thing that
changed.
before: None, after: None (nothing to diff) produces no changes.
before: None, after: Some(record) (a create) produces one change per
leaf path in record, every one with before: None. before: Some(record), after: None (a delete) is the mirror: one change per leaf
path in record, every one with after: None.