summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Orchard <if_coding@fastmail.com>2021-07-28 23:51:02 -0700
committerDavid Orchard <if_coding@fastmail.com>2021-08-15 10:31:38 -0700
commit7134592270190c28e538d580a3d55b0f1ff753f8 (patch)
treeda8d736b8cd4fdc3d4d10bf990851623bb5d61ef
parentf14adeb0984f81883cd85c6590c960f4dcadb59b (diff)
Preserve map order when merging
-rw-r--r--src/path/mod.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/path/mod.rs b/src/path/mod.rs
index 04c424c..b056467 100644
--- a/src/path/mod.rs
+++ b/src/path/mod.rs
@@ -209,7 +209,11 @@ impl Expression {
_ => {
if let ValueKind::Table(ref mut map) = root.kind {
// Just do a simple set
- map.insert(id.clone(), value);
+ if let Some(existing) = map.get_mut(id) {
+ *existing = value;
+ } else {
+ map.insert(id.clone(), value);
+ }
}
}
}