pub fn merge_maps<I, V>(iter: I) -> Value
Expand description
Utility function to merge multiple maps into a single one.
If values are passed that are not maps, they are for the most part ignored.
They cannot be enumerated, but attribute lookups can still work. That’s
because get_value
is forwarded through
to all objects.
This is the operation the context!
macro uses behind
the scenes. The merge is done lazily which means that any dynamic object
that behaves like a map can be used here. Note though that the order of
this function is inverse to what the macro does.
use minijinja::{context, value::merge_maps};
let ctx1 = context!{
name => "John",
age => 30
};
let ctx2 = context!{
location => "New York",
age => 25 // This will be overridden by ctx1's value
};
let merged = merge_maps([ctx1, ctx2]);