Skip to content

Commit 392c5dc

Browse files
committed
---
yaml --- r: 122639 b: refs/heads/snap-stage3 c: c3cf3b3 h: refs/heads/master i: 122637: 736fe50 122635: 38ac6b0 122631: 638da93 122623: 5ac4ed1 v: v3
1 parent 3513ebd commit 392c5dc

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 1bff1ff810dcfa8064c11e2b84473f053d1f69f1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 035914edcfb19bf531eb633fba54c68b53fbe8d8
4+
refs/heads/snap-stage3: c3cf3b3fb10754f92c0703062c39726b52726298
55
refs/heads/try: 2e9d9477b848cec778ca3f07ecdf0aea6ade23de
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)