summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYounessBird <67457600+YounessBird@users.noreply.github.com>2022-07-05 06:10:52 +0100
committerYounessBird <67457600+YounessBird@users.noreply.github.com>2022-07-14 10:22:46 +0100
commitd2ee90ea23281b057dffa6515b274e5c7b82cf87 (patch)
tree2a9425c3ba7ae638b5daa676b92a01086233a528
parent9c28d1279d470f4d2a6c3e2c7337382008ef85a5 (diff)
turn keys to lowercase to enable cross overrides
-rw-r--r--src/path/mod.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/path/mod.rs b/src/path/mod.rs
index 7456aa3..b3773d1 100644
--- a/src/path/mod.rs
+++ b/src/path/mod.rs
@@ -120,7 +120,7 @@ impl Expression {
match *self {
Self::Identifier(ref id) => match root.kind {
ValueKind::Table(ref mut map) => Some(
- map.entry(id.clone())
+ map.entry(id.to_lowercase())
.or_insert_with(|| Value::new(None, ValueKind::Nil)),
),
@@ -131,7 +131,7 @@ impl Expression {
Some(value) => {
if let ValueKind::Table(ref mut map) = value.kind {
Some(
- map.entry(key.clone())
+ map.entry(key.to_lowercase())
.or_insert_with(|| Value::new(None, ValueKind::Nil)),
)
} else {
@@ -139,7 +139,7 @@ impl Expression {
if let ValueKind::Table(ref mut map) = value.kind {
Some(
- map.entry(key.clone())
+ map.entry(key.to_lowercase())
.or_insert_with(|| Value::new(None, ValueKind::Nil)),
)
} else {
@@ -194,7 +194,7 @@ impl Expression {
ValueKind::Table(ref incoming_map) => {
// Pull out another table
let target = if let ValueKind::Table(ref mut map) = root.kind {
- map.entry(id.clone())
+ map.entry(id.to_lowercase())
.or_insert_with(|| Map::<String, Value>::new().into())
} else {
unreachable!();
@@ -202,17 +202,17 @@ impl Expression {
// Continue the deep merge
for (key, val) in incoming_map {
- Self::Identifier(key.clone()).set(target, val.clone());
+ Self::Identifier(key.to_lowercase()).set(target, val.clone());
}
}
_ => {
if let ValueKind::Table(ref mut map) = root.kind {
// Just do a simple set
- if let Some(existing) = map.get_mut(id) {
+ if let Some(existing) = map.get_mut(&id.to_lowercase()) {
*existing = value;
} else {
- map.insert(id.clone(), value);
+ map.insert(id.to_lowercase(), value);
}
}
}
@@ -225,7 +225,7 @@ impl Expression {
// Didn't find a table. Oh well. Make a table and do this anyway
*parent = Map::<String, Value>::new().into();
}
- Self::Identifier(key.clone()).set(parent, value);
+ Self::Identifier(key.to_lowercase()).set(parent, value);
}
}