⚰️ [config] Elimina código no usado

This commit is contained in:
Manuel Cillero 2022-10-21 20:48:14 +02:00
parent 3167c3780d
commit 33415a14bb
2 changed files with 1 additions and 166 deletions

View file

@ -30,92 +30,6 @@ fn sindex_to_uindex(index: isize, len: usize) -> usize {
}
impl Expression {
pub fn get(self, root: &Value) -> Option<&Value> {
match self {
Expression::Identifier(id) => {
match root.kind {
// `x` access on a table is equivalent to: map[x].
ValueKind::Table(ref map) => map.get(&id),
// All other variants return None.
_ => None,
}
}
Expression::Child(expr, key) => {
match expr.get(root) {
Some(value) => {
match value.kind {
// Access on a table is identical to Identifier, it just forwards.
ValueKind::Table(ref map) => map.get(&key),
// All other variants return None.
_ => None,
}
}
_ => None,
}
}
Expression::Subscript(expr, index) => match expr.get(root) {
Some(value) => match value.kind {
ValueKind::Array(ref array) => {
let index = sindex_to_uindex(index, array.len());
if index >= array.len() {
None
} else {
Some(&array[index])
}
}
_ => None,
},
_ => None,
},
}
}
pub fn get_mut<'a>(&self, root: &'a mut Value) -> Option<&'a mut Value> {
match *self {
Expression::Identifier(ref id) => match root.kind {
ValueKind::Table(ref mut map) => map.get_mut(id),
_ => None,
},
Expression::Child(ref expr, ref key) => match expr.get_mut(root) {
Some(value) => match value.kind {
ValueKind::Table(ref mut map) => map.get_mut(key),
_ => None,
},
_ => None,
},
Expression::Subscript(ref expr, index) => match expr.get_mut(root) {
Some(value) => match value.kind {
ValueKind::Array(ref mut array) => {
let index = sindex_to_uindex(index, array.len());
if index >= array.len() {
None
} else {
Some(&mut array[index])
}
}
_ => None,
},
_ => None,
},
}
}
pub fn get_mut_forcibly<'a>(&self, root: &'a mut Value) -> Option<&'a mut Value> {
match *self {
Expression::Identifier(ref id) => match root.kind {