Skip to main content

Module toml_merge

Module toml_merge 

Source
Expand description

Generic TOML table inheritance merge — the primitive both the language plugins (defaults.toml ⊕ [base] ⊕ <lang>.toml) and the CLI (built-in defaults ⊕ a project code-ranker.toml) layer config with. Lives in code-ranker-plugin-api so neither consumer reaches into a sibling crate.

§Merge semantics (deep_merge)

For each key of overlay applied onto base:

  • table vs table → recurse (per-key deep merge).
  • [[presets]] array of tables → merge by id: an overlay preset with an id already present in the base replaces that entry in place; a new id is appended.
  • array patched by an op-table ({add,remove,replace,clear,prepend,…}) → the inherited list is mutated in place (see crate::list_override); a plain array still replaces it wholesale.
  • any other value (scalar, plain array, table-vs-non-table) → the overlay value replaces the base value outright.

Keys present only in one side are kept as-is.

Functions§

deep_merge
Deep-merge overlay onto base (see module docs for the rules).
merge_presets
Merge two [[presets]] arrays by the id field: an overlay preset whose id matches a base entry replaces it in place; a new id is appended. Entries without a string id are appended verbatim.