about summary refs log tree commit diff
path: root/compiler/rustc_serialize/src/json.rs
diff options
context:
space:
mode:
authorAdam Bratschi-Kaye <ark.email@gmail.com>2021-05-27 10:21:53 +0200
committerAdam Bratschi-Kaye <ark.email@gmail.com>2021-06-17 21:48:02 +0200
commit88b01f1178a86e22742103e8e1f385163e844fbd (patch)
treea0dd56559fd768ed16b04093174e437aa0ba444c /compiler/rustc_serialize/src/json.rs
parent0ef2b4a29bf70e8984d0d2febb7a546856c554a0 (diff)
downloadrust-88b01f1178a86e22742103e8e1f385163e844fbd.tar.gz
rust-88b01f1178a86e22742103e8e1f385163e844fbd.zip
Emit warnings for unused fields in custom targets.
Diffstat (limited to 'compiler/rustc_serialize/src/json.rs')
-rw-r--r--compiler/rustc_serialize/src/json.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_serialize/src/json.rs b/compiler/rustc_serialize/src/json.rs
index b79adb6f7bc..4d213207fb6 100644
--- a/compiler/rustc_serialize/src/json.rs
+++ b/compiler/rustc_serialize/src/json.rs
@@ -1114,6 +1114,15 @@ impl Json {
         }
     }
 
+    /// If the Json value is an Object, deletes the value associated with the
+    /// provided key from the Object and returns it. Otherwise, returns None.
+    pub fn remove_key(&mut self, key: &str) -> Option<Json> {
+        match *self {
+            Json::Object(ref mut map) => map.remove(key),
+            _ => None,
+        }
+    }
+
     /// Attempts to get a nested Json Object for each key in `keys`.
     /// If any key is found not to exist, `find_path` will return `None`.
     /// Otherwise, it will return the Json value associated with the final key.