Debian Codegraph @

third_party/rust/serde_with_macros/tests/serde_as_issue_538.rs

raw
1 //! Check for the correct processing of `ExprGroup`s in types
2 //!
3 //! They occur when the types is passed in as a `macro_rules` argument like here.
4 //! <https://github.com/jonasbb/serde_with/issues/538>
5
6 macro_rules! t {
7 ($($param:ident : $ty:ty),*) => {
8 #[derive(Default)]
9 #[serde_with_macros::apply(
10 crate = "serde_with_macros",
11 Option => #[serde(skip_serializing_if = "Option::is_none")],
12 )]
13 #[derive(serde::Serialize)]
14 struct Data {
15 a: Option<String>,
16 b: Option<u64>,
17 c: Option<String>,
18 $(pub $param: $ty),*
19 }
20 }
21 }
22
23 t!(d: Option<bool>);
24
25 #[test]
26 fn t() {
27 let expected = r#"{}"#;
28 let data = Data::default();
29 assert_eq!(expected, serde_json::to_string(&data).unwrap());
30 }