diff options
| author | Loïc BRANSTETT <lolo.branstett@numericable.fr> | 2022-03-28 01:08:17 +0200 |
|---|---|---|
| committer | Loïc BRANSTETT <lolo.branstett@numericable.fr> | 2022-04-03 21:29:57 +0200 |
| commit | ce61d4044d7621fd190a2ddd1f51fa78e2941518 (patch) | |
| tree | 6d9fd86e7cc978dde4ae2810d5e3fe2888c8a74d /compiler/rustc_serialize/src/json.rs | |
| parent | ccff48f97b7a4438b9818f8ff0f60c1cd01cdbeb (diff) | |
| download | rust-ce61d4044d7621fd190a2ddd1f51fa78e2941518.tar.gz rust-ce61d4044d7621fd190a2ddd1f51fa78e2941518.zip | |
Replace every Vec in Target(Options) with it's Cow equivalent
Diffstat (limited to 'compiler/rustc_serialize/src/json.rs')
| -rw-r--r-- | compiler/rustc_serialize/src/json.rs | 9 |
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(); |
