Skip to main content

merge

Function merge 

Source
pub fn merge<A: Clone>(
    base: BuildOutput<A>,
    overlay: BuildOutput<A>,
) -> Merged<A>
Expand description

Merges a base (defaults) BuildOutput with an overlay (user config) BuildOutput, returning the combined result with advisory notes.

§Merge semantics

  • Layers: the layer sets are unioned. For each layer name present in both base and overlay, bindings are merged chord-by-chord: the overlay chord wins silently (it is the user’s override). A MergeNote::Overrode is emitted for each overridden chord.
  • Tombstones (overlay.unbinds): for each chord listed as an unbind in the overlay, the chord is removed from the corresponding base layer (if present). A MergeNote::Unbound note is emitted for successful removals; MergeNote::UnbindMiss when the chord was absent from the base.
  • Sequences: the overlay’s sequences are folded into the base’s. An exact-match sequence in the overlay silently replaces the base’s. A sequence in the overlay that is a prefix of (or is prefixed by) a sequence in the base causes the base sequence to be dropped; a MergeNote::DroppedSequence note is emitted.
  • Warnings: the merged output.warnings is the concatenation of base.warnings and overlay.warnings. Merge notes go to notes, never to output.warnings.

Override operations are intentionally silent in output.warnings so that a caller gating on output.warnings.is_empty() (deny-warnings mode) is not triggered by the user legitimately overriding a default binding.

§Bound: A: Clone

merge requires A: Clone because it copies actions from the overlay into the merged map. SequenceKeymap::bindings yields shared references only (there is no by-value iterator), so cloning is the only way to move sequence actions across maps without unsafe code. This bound is on merge alone and is not propagated to any core type.