Allow struct attributes
This commit is contained in:
parent
d1d424dc73
commit
b644597e8c
|
@ -19,7 +19,9 @@ mod macros;
|
|||
mod tests {
|
||||
// just tests that the macro compiles
|
||||
crate::query_def! {
|
||||
/// Foo doc.
|
||||
Foo(FooDef) {
|
||||
/// Field doc.
|
||||
#[serde(flatten)]
|
||||
bar: (Bar),
|
||||
baz: (bool),
|
||||
|
@ -27,6 +29,7 @@ mod tests {
|
|||
bars_by_bazs: 'map (bool, Bar),
|
||||
}
|
||||
|
||||
/// Bar doc.
|
||||
Bar(BarDef) {
|
||||
baz_inner: (bool),
|
||||
}
|
||||
|
|
|
@ -83,18 +83,28 @@ macro_rules! query_def_filter {
|
|||
#[macro_export]
|
||||
macro_rules! query_def {
|
||||
(
|
||||
$($vis:vis $data:ident($def:ident) {
|
||||
$(
|
||||
$(#[$field_meta:meta])
|
||||
$(
|
||||
$(#[$meta:meta])
|
||||
*
|
||||
$vis:vis $data:ident(
|
||||
$(#[$def_meta:meta])
|
||||
*
|
||||
$field:ident: $($qualifier:lifetime)? ($($type:tt)+),
|
||||
)+
|
||||
})
|
||||
$def:ident
|
||||
) {
|
||||
$(
|
||||
$(#[$field_meta:meta])
|
||||
*
|
||||
$field:ident: $($qualifier:lifetime)? ($($type:tt)+),
|
||||
)+
|
||||
}
|
||||
)
|
||||
*
|
||||
) => {
|
||||
$(
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
|
||||
$(#[$meta])
|
||||
*
|
||||
$vis struct $data {
|
||||
$(
|
||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||
|
@ -106,6 +116,8 @@ macro_rules! query_def {
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
|
||||
$(#[$def_meta])
|
||||
*
|
||||
$vis struct $def {
|
||||
$(
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
|
|
Loading…
Reference in New Issue