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 implements EasyPeek
.
For enums, if first variant is prefixed by !
it becomes a default variant that is parsed if no other variants peeking succeeds.
Variants prefixed with ?
are skipped during parsing and peeking.
For enums EasyPeek
is implemented if enum does not have a default variant.
First field in all non-default non-skipped variants must implement EasyPeek
.
Therefore unit and empty tuple and struct-like variants may be present but must be marked as default or skipped.