fn dumb_config_merge(a: Value, b: Value) -> Value {
    match (a, b) {
        (Value::Mapping(mut a), Value::Mapping(b)) => {
            for (key, b_value) in b {
                let value = match a.remove(&key) {
                    None => b_value,
                    Some(a_value) => dumb_config_merge(a_value, b_value),
                };
                a.insert(key, value);
            }
            Value::Mapping(a)
        },
        (_, b) => b,
    }
}
/// A simplistic config-merging function which operates directly on the yaml representation,
/// independent of what is being deserialized. This sort of approach is inherently flawed,
/// but easiest to implement.
///
/// Given two mappings, it takes the union of their keys and recursively merges their intersection.
/// Given any other two values, it prefers 'b'.
///
/// It will have trouble overriding the values of struct-like enum variants due to their
/// representation as a mapping with one key.
A simplistic config-merging function which operates directly on the yaml representation,
independent of what is being deserialized. This sort of approach is inherently flawed,
but easiest to implement.

Given two mappings, it takes the union of their keys and recursively merges their intersection.
Given any other two values, it prefers 'b'.

It will have trouble overriding the values of struct-like enum variants due to their
representation as a mapping with one key.
A simplistic config - merging function which operates directly on the yaml representation independent of what is being deserialized . This sort of approach is inherently flawed but easiest to implement . Given two mappings it takes the union of their keys and recursively merges their intersection . Given any other two values it prefers ' b ' . It will have trouble overriding the values of struct - like enum variants due to their representation as a mapping with one key .
fn dumb_config_merge(a: Value, b: Value) -> Value {
    match (a, b) {
        (Value::Mapping(mut a), Value::Mapping(b)) => {
            for (key, b_value) in b {
                let value = match a.remove(&key) {
                    None => b_value,
                    Some(a_value) => dumb_config_merge(a_value, b_value),
                };
                a.insert(key, value);
            }
            Value::Mapping(a)
        },
        (_, b) => b,
    }
}
fn dumb_config_merge ( a : Value , b : Value ) -> Value { match ( a , b ) { ( Value :: Mapping ( mut a ) , Value :: Mapping ( b ) ) => { for ( key , b_value ) in b { let value = match a . remove ( & key ) { None => b_value , Some ( a_value ) => dumb_config_merge ( a_value , b_value ) , } ; a . insert ( key , value ) ; } Value :: Mapping ( a ) } , ( _ , b ) => b , } }
A simplistic config-merging function which operates directly on the yaml representation,
independent of what is being deserialized.
A simplistic config - merging function which operates directly on the yaml representation independent of what is being deserialized .
a
Value
b
Value
a
Value
b
Value