Macro proc_easy::easy_parse
source · [−]macro_rules! easy_parse {
(
$(#[$meta:meta])*
$vis:vis struct $name:ident;
) => { ... };
(
$(#[$meta:meta])*
$vis:vis struct $name:ident ();
) => { ... };
(
$(#[$meta:meta])*
$vis:vis struct $name:ident {}
) => { ... };
(
$(#[$meta:meta])*
$vis:vis struct $name:ident {
$(#[$hmeta:meta])* $hvis:vis $hname:ident : $htype:ty
$(, $(#[$fmeta:meta])* $fvis:vis $fname:ident : $ftype:ty)*
$(,)?
}
) => { ... };
(
$(#[$meta:meta])*
$vis:vis struct $name:ident (
$(#[$hmeta:meta])* $hvis:vis $htype:ty
$(, $(#[$fmeta:meta])* $fvis:vis $ftype:ty)*
$(,)?
);
) => { ... };
(
$(#[$meta:meta])*
$vis:vis enum $name:ident {
$(#[$vdmeta:meta])* ! $vdname:ident $( ( $($vdt:tt)* ) )? $( { $($vdr:tt)* } )?,
$($(#[$vmeta:meta])* $( ? $vsname:ident )? $( $vname:ident )? $( ( $($vt:tt)* ) )? $( { $($vr:tt)* } )?, )*
}
) => { ... };
(
$(#[$meta:meta])*
$vis:vis enum $name:ident {
$($(#[$vmeta:meta])* $( ? $vsname:ident )? $( $vname:ident )? $( ( $($vt:tt)* ) )? $( { $($vr:tt)* } )?, )*
}
) => { ... };
}
Expand description
Defines structure or enum and implements Parse
for it
Implements EasyPeek
for structs if first field is prefixed with @
. That field’s type must implement EasyPeek
itself.
For enums, if variant is prefixed by !
it becomes a default variant that is parsed if other variants peeking fails.
Variants prefixed with ?
are skipped during parsing and picking.
For enums EasyPeek
is implemented if enum does not have a default variant.
First field in enum non-default variants must implement EasyPeek
.
Note that unit, empty tuple and struct-like variants may be present but must be marked as default or skipped.