Simplify the implementation of str's index_or_insert

This commit is contained in:
Matt Kraai
2018-02-27 09:35:16 -08:00
committed by GitHub
parent d78b23548e
commit ead6d6e6e9

View File

@@ -109,9 +109,7 @@ impl Index for str {
}
fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value {
if let Value::Null = *v {
let mut map = Map::new();
map.insert(self.to_owned(), Value::Null);
*v = Value::Object(map);
*v = Value::Object(Map::new());
}
match *v {
Value::Object(ref mut map) => {