@@ -73,3 +73,18 @@ impl From<&toml::Value> for Value {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Value {
|
||||
pub fn get(&self, path: &[&str]) -> Option<&Value> {
|
||||
match path.split_first() {
|
||||
Some((current, rest)) => match self {
|
||||
Value::Map(map) => match map.get(¤t.to_string()) {
|
||||
Some(value) => value.get(rest),
|
||||
None => None,
|
||||
},
|
||||
_ => None,
|
||||
},
|
||||
None => Some(self),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user