diff options
author | Daniel Eades <danieleades@hotmail.com> | 2022-01-29 14:01:09 +0100 |
---|---|---|
committer | Daniel Eades <danieleades@hotmail.com> | 2022-01-29 14:01:49 +0100 |
commit | aaa1601c14d029c711dbba28bdc61c3554278fb0 (patch) | |
tree | 316a54821ca8264126bc01a008ec19ebb8dd793c /src | |
parent | c1d67fe15b3a9cf1a0064fbb10041c242523dc73 (diff) |
simplify some match blocks
Diffstat (limited to 'src')
-rw-r--r-- | src/path/mod.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/path/mod.rs b/src/path/mod.rs index 8d59999..7456aa3 100644 --- a/src/path/mod.rs +++ b/src/path/mod.rs @@ -221,22 +221,18 @@ impl Expression { Self::Child(ref expr, ref key) => { if let Some(parent) = expr.get_mut_forcibly(root) { - if let ValueKind::Table(_) = parent.kind { - Self::Identifier(key.clone()).set(parent, value); - } else { + if !matches!(parent.kind, ValueKind::Table(_)) { // 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.clone()).set(parent, value); } } Self::Subscript(ref expr, index) => { if let Some(parent) = expr.get_mut_forcibly(root) { - match parent.kind { - ValueKind::Array(_) => (), - _ => *parent = Vec::<Value>::new().into(), + if !matches!(parent.kind, ValueKind::Array(_)) { + *parent = Vec::<Value>::new().into() } if let ValueKind::Array(ref mut array) = parent.kind { |