about summary refs log tree commit diff
path: root/compiler/rustc_serialize/src/json.rs
diff options
context:
space:
mode:
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 9847fde3c49..c915dd5bbf6 100644
--- a/compiler/rustc_serialize/src/json.rs
+++ b/compiler/rustc_serialize/src/json.rs
@@ -2247,6 +2247,15 @@ impl<A: ToJson> ToJson for Vec<A> {
     }
 }
 
+impl<'a, A: ToJson> ToJson for Cow<'a, [A]>
+where
+    [A]: ToOwned,
+{
+    fn to_json(&self) -> Json {
+        Json::Array(self.iter().map(|elt| elt.to_json()).collect())
+    }
+}
+
 impl<T: ToString, A: ToJson> ToJson for BTreeMap<T, A> {
     fn to_json(&self) -> Json {
         let mut d = BTreeMap::new();