From ccff48f97b7a4438b9818f8ff0f60c1cd01cdbeb Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Tue, 22 Mar 2022 11:43:05 +0100 Subject: Replace every `String` in Target(Options) with `Cow<'static, str>` --- compiler/rustc_serialize/src/json.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/rustc_serialize') 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),* ) => { -- cgit 1.4.1-3-g733a5