diff options
author | Joel Gallant <joel@joelgallant.me> | 2020-10-11 09:44:24 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-11 09:44:24 -0600 |
commit | d9fc453c7b77bfbb7d0b0c8fb2be886b3c1508ff (patch) | |
tree | b1364beef0d67ba33718750c070d351b3a23c3b9 /src/path/mod.rs | |
parent | 6c51d3b6b2dbe49d1b40fd0f0326b73f16357f72 (diff) | |
parent | 1eb140881b26328ed1b17615fee32427baafadf6 (diff) |
Merge pull request #155 from matthiasbeyer/format
Run cargo-fmt
Diffstat (limited to 'src/path/mod.rs')
-rw-r--r-- | src/path/mod.rs | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/path/mod.rs b/src/path/mod.rs index 3916010..ac28400 100644 --- a/src/path/mod.rs +++ b/src/path/mod.rs @@ -151,34 +151,30 @@ impl Expression { _ => None, }, - Expression::Subscript(ref expr, index) => { - match expr.get_mut_forcibly(root) { - Some(value) => { - match value.kind { - ValueKind::Array(_) => (), - _ => *value = Vec::<Value>::new().into(), - } - - match value.kind { - ValueKind::Array(ref mut array) => { - let index = sindex_to_uindex(index, array.len()); + Expression::Subscript(ref expr, index) => match expr.get_mut_forcibly(root) { + Some(value) => { + match value.kind { + ValueKind::Array(_) => (), + _ => *value = Vec::<Value>::new().into(), + } - if index >= array.len() { - array.resize( - (index + 1) as usize, - Value::new(None, ValueKind::Nil), - ); - } + match value.kind { + ValueKind::Array(ref mut array) => { + let index = sindex_to_uindex(index, array.len()); - Some(&mut array[index]) + if index >= array.len() { + array + .resize((index + 1) as usize, Value::new(None, ValueKind::Nil)); } - _ => None, + Some(&mut array[index]) } + + _ => None, } - _ => None, } - } + _ => None, + }, } } @@ -246,10 +242,7 @@ impl Expression { if let ValueKind::Array(ref mut array) = parent.kind { let uindex = sindex_to_uindex(index, array.len()); if uindex >= array.len() { - array.resize( - (uindex + 1) as usize, - Value::new(None, ValueKind::Nil), - ); + array.resize((uindex + 1) as usize, Value::new(None, ValueKind::Nil)); } array[uindex] = value; |