Skip to main content

gen_platform/
merge.rs

1//! Typed merge strategies for folding per-variant overrides.
2
3/// How a `Dispatcher<V, C, O>` combines successive overrides as
4/// it folds over a list of variants.
5///
6/// The default `OverrideLast` mirrors Nix attrset `//` (later
7/// wins). `AccumulateList` mirrors `++` (concatenate). Custom
8/// strategies are handled by the consumer's `O` type implementing
9/// `Default + std::ops::Add` (or whatever shape fits).
10#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
11pub enum MergeStrategy {
12    /// Last variant's override replaces overlapping keys. Default.
13    #[default]
14    OverrideLast,
15    /// Accumulate overrides additively — typically used when `O` is
16    /// a `Vec<T>` and each helper returns one element to append.
17    Accumulate,
18    /// Caller-supplied custom merge — the consumer's `O` type is
19    /// responsible for implementing the semantics (e.g. via a
20    /// `Monoid` impl).
21    Custom,
22}