mirror of
https://github.com/serde-rs/json.git
synced 2025-10-02 15:26:00 +00:00
Allow but ignore trailing comma in test macros
This commit is contained in:
parent
f38e6b5c16
commit
c594eb00fc
@ -2,7 +2,7 @@ macro_rules! json_str {
|
|||||||
([]) => {
|
([]) => {
|
||||||
"[]"
|
"[]"
|
||||||
};
|
};
|
||||||
([ $e0:tt $(, $e:tt)* ]) => {
|
([ $e0:tt $(, $e:tt)* $(,)? ]) => {
|
||||||
concat!("[",
|
concat!("[",
|
||||||
json_str!($e0),
|
json_str!($e0),
|
||||||
$(",", json_str!($e),)*
|
$(",", json_str!($e),)*
|
||||||
@ -11,7 +11,7 @@ macro_rules! json_str {
|
|||||||
({}) => {
|
({}) => {
|
||||||
"{}"
|
"{}"
|
||||||
};
|
};
|
||||||
({ $k0:tt : $v0:tt $(, $k:tt : $v:tt)* }) => {
|
({ $k0:tt : $v0:tt $(, $k:tt : $v:tt)* $(,)? }) => {
|
||||||
concat!("{",
|
concat!("{",
|
||||||
stringify!($k0), ":", json_str!($v0),
|
stringify!($k0), ":", json_str!($v0),
|
||||||
$(",", stringify!($k), ":", json_str!($v),)*
|
$(",", stringify!($k), ":", json_str!($v),)*
|
||||||
@ -35,7 +35,7 @@ macro_rules! pretty_str_impl {
|
|||||||
($indent:expr, []) => {
|
($indent:expr, []) => {
|
||||||
"[]"
|
"[]"
|
||||||
};
|
};
|
||||||
($indent:expr, [ $e0:tt $(, $e:tt)* ]) => {
|
($indent:expr, [ $e0:tt $(, $e:tt)* $(,)? ]) => {
|
||||||
concat!("[\n ",
|
concat!("[\n ",
|
||||||
$indent, pretty_str_impl!(concat!(" ", $indent), $e0),
|
$indent, pretty_str_impl!(concat!(" ", $indent), $e0),
|
||||||
$(",\n ", $indent, pretty_str_impl!(concat!(" ", $indent), $e),)*
|
$(",\n ", $indent, pretty_str_impl!(concat!(" ", $indent), $e),)*
|
||||||
@ -44,7 +44,7 @@ macro_rules! pretty_str_impl {
|
|||||||
($indent:expr, {}) => {
|
($indent:expr, {}) => {
|
||||||
"{}"
|
"{}"
|
||||||
};
|
};
|
||||||
($indent:expr, { $k0:tt : $v0:tt $(, $k:tt : $v:tt)* }) => {
|
($indent:expr, { $k0:tt : $v0:tt $(, $k:tt : $v:tt)* $(,)? }) => {
|
||||||
concat!("{\n ",
|
concat!("{\n ",
|
||||||
$indent, stringify!($k0), ": ", pretty_str_impl!(concat!(" ", $indent), $v0),
|
$indent, stringify!($k0), ": ", pretty_str_impl!(concat!(" ", $indent), $v0),
|
||||||
$(",\n ", $indent, stringify!($k), ": ", pretty_str_impl!(concat!(" ", $indent), $v),)*
|
$(",\n ", $indent, stringify!($k), ": ", pretty_str_impl!(concat!(" ", $indent), $v),)*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user