diff options
Diffstat (limited to 'src/path/mod.rs')
-rw-r--r-- | src/path/mod.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/path/mod.rs b/src/path/mod.rs index f63deee..3916010 100644 --- a/src/path/mod.rs +++ b/src/path/mod.rs @@ -152,7 +152,6 @@ impl Expression { }, Expression::Subscript(ref expr, index) => { - let mut do_again = false; match expr.get_mut_forcibly(root) { Some(value) => { match value.kind { @@ -183,7 +182,7 @@ impl Expression { } } - pub fn set<'a>(&self, root: &'a mut Value, value: Value) { + pub fn set(&self, root: &mut Value, value: Value) { match *self { Expression::Identifier(ref id) => { // Ensure that root is a table @@ -244,20 +243,16 @@ impl Expression { _ => *parent = Vec::<Value>::new().into(), } - match parent.kind { - ValueKind::Array(ref mut array) => { - let uindex = sindex_to_uindex(index, array.len()); - if uindex >= array.len() { - array.resize( - (uindex + 1) as usize, - Value::new(None, ValueKind::Nil), - ); - } - - array[uindex] = value.clone(); + 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[uindex] = value; } } } |