Macro nom::named_attr [−][src]
macro_rules! named_attr {
($(#[$attr : meta]) *, $vis : vis $name : ident($i : ty) -> $o : ty, $submac :
ident! ($($args : tt) *)) => { ... };
($(#[$attr : meta]) *, $vis : vis $name : ident < $i : ty, $o : ty, $e : ty >,
$submac : ident! ($($args : tt) *)) => { ... };
($(#[$attr : meta]) *, $vis : vis $name : ident < $i : ty, $o : ty >, $submac
: ident! ($($args : tt) *)) => { ... };
($(#[$attr : meta]) *, $vis : vis $name : ident < $o : ty >, $submac : ident!
($($args : tt) *)) => { ... };
($(#[$attr : meta]) *, $vis : vis $name : ident, $submac : ident!
($($args : tt) *)) => { ... };
}
Expand description
Makes a function from a parser combination, with attributes
The usage of this macro is almost identical to named!
, except that
you also pass attributes to be attached to the generated function.
This is ideal for adding documentation to your parser.
Create my_function as if you wrote it with the doc comment /// My Func:
named_attr!(#[doc = "My Func"], my_function( &[u8] ) -> &[u8], tag!("abcd"));
Also works for pub functions, and multiple lines:
named_attr!(#[doc = "My Func\nRecognise abcd"], pub my_function, tag!("abcd"));
Multiple attributes can be passed if required:
named_attr!(#[doc = "My Func"] #[inline(always)], pub my_function, tag!("abcd"));