Skip to content

Commit 245e3cf

Browse files
committed
---
yaml --- r: 152979 b: refs/heads/try2 c: c3cf3b3 h: refs/heads/master i: 152977: 4471d89 152975: bf52d02 v: v3
1 parent ad80d24 commit 245e3cf

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 035914edcfb19bf531eb633fba54c68b53fbe8d8
8+
refs/heads/try2: c3cf3b3fb10754f92c0703062c39726b52726298
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libserialize/json.rs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,25 +2015,37 @@ impl ToJson for String {
20152015
fn to_json(&self) -> Json { String((*self).clone()) }
20162016
}
20172017

2018-
impl<A: ToJson, B: ToJson> ToJson for (A, B) {
2019-
fn to_json(&self) -> Json {
2020-
match *self {
2021-
(ref a, ref b) => {
2022-
List(vec![a.to_json(), b.to_json()])
2018+
macro_rules! tuple_impl {
2019+
// use variables to indicate the arity of the tuple
2020+
($($tyvar:ident),* ) => {
2021+
// the trailing commas are for the 1 tuple
2022+
impl<
2023+
$( $tyvar : ToJson ),*
2024+
> ToJson for ( $( $tyvar ),* , ) {
2025+
2026+
#[inline]
2027+
#[allow(uppercase_variables)]
2028+
fn to_json(&self) -> Json {
2029+
match *self {
2030+
($(ref $tyvar),*,) => List(vec![$($tyvar.to_json()),*])
2031+
}
20232032
}
20242033
}
20252034
}
20262035
}
20272036

2028-
impl<A: ToJson, B: ToJson, C: ToJson> ToJson for (A, B, C) {
2029-
fn to_json(&self) -> Json {
2030-
match *self {
2031-
(ref a, ref b, ref c) => {
2032-
List(vec![a.to_json(), b.to_json(), c.to_json()])
2033-
}
2034-
}
2035-
}
2036-
}
2037+
tuple_impl!{A}
2038+
tuple_impl!{A, B}
2039+
tuple_impl!{A, B, C}
2040+
tuple_impl!{A, B, C, D}
2041+
tuple_impl!{A, B, C, D, E}
2042+
tuple_impl!{A, B, C, D, E, F}
2043+
tuple_impl!{A, B, C, D, E, F, G}
2044+
tuple_impl!{A, B, C, D, E, F, G, H}
2045+
tuple_impl!{A, B, C, D, E, F, G, H, I}
2046+
tuple_impl!{A, B, C, D, E, F, G, H, I, J}
2047+
tuple_impl!{A, B, C, D, E, F, G, H, I, J, K}
2048+
tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}
20372049

20382050
impl<'a, A: ToJson> ToJson for &'a [A] {
20392051
fn to_json(&self) -> Json { List(self.iter().map(|elt| elt.to_json()).collect()) }

0 commit comments

Comments
 (0)