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-07-29 00:05:27 -0700
commitcd5e8d5d6acab38ab42a7318cbed428b7acf22af (patch)
tree960030acccd209fd79cc96d7189ca4a4c435aa4f
parent29eca0d23b8ef7466b308d3c03f859109d37c1dd (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);
+ }
}
}
}