Skip to main content

merge_with

Function merge_with 

Source
pub fn merge_with<F>(base: Value, overlay: Value, array_strategy: F) -> Value
where F: FnMut(&str) -> ArrayStrategy,
Expand description

Deep-merge overlay onto base, choosing an array strategy per key.

Objects merge recursively; on a key collision the overlay value wins. When both sides hold an array at the same key, array_strategy is consulted with that key to decide ArrayStrategy::Replace vs ArrayStrategy::Concat. Type mismatches (for example object vs scalar) resolve to the overlay.

The mechanism is framework-agnostic: identity rules, duplicate detection, and “which keys are mergeable lists” are caller policy expressed through array_strategy, not built in here.