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.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_serialize/src/json.rs b/compiler/rustc_serialize/src/json.rs
index 0cbea3a07a8..9847fde3c49 100644
--- a/compiler/rustc_serialize/src/json.rs
+++ b/compiler/rustc_serialize/src/json.rs
@@ -170,6 +170,7 @@ use self::JsonEvent::*;
 use self::ParserError::*;
 use self::ParserState::*;
 
+use std::borrow::Cow;
 use std::collections::{BTreeMap, HashMap};
 use std::mem::swap;
 use std::num::FpCategory as Fp;
@@ -2196,6 +2197,12 @@ impl ToJson for string::String {
     }
 }
 
+impl<'a> ToJson for Cow<'a, str> {
+    fn to_json(&self) -> Json {
+        Json::String(self.to_string())
+    }
+}
+
 macro_rules! tuple_impl {
     // use variables to indicate the arity of the tuple
     ($($tyvar:ident),* ) => {