Macro peel_ip::prelude::named_attr
[−]
macro_rules! named_attr { ( $ ( # [ $ attr : meta ] ) * , $ name : ident ( $ i : ty ) -> $ o : ty , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; ( $ ( # [ $ attr : meta ] ) * , $ name : ident < $ i : ty , $ o : ty , $ e : ty > , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; ( $ ( # [ $ attr : meta ] ) * , $ name : ident < $ i : ty , $ o : ty > , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; ( $ ( # [ $ attr : meta ] ) * , $ name : ident < $ o : ty > , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; ( $ ( # [ $ attr : meta ] ) * , $ name : ident , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; ( $ ( # [ $ attr : meta ] ) * , pub $ name : ident ( $ i : ty ) -> $ o : ty , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; ( $ ( # [ $ attr : meta ] ) * , pub $ name : ident < $ i : ty , $ o : ty , $ e : ty > , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; ( $ ( # [ $ attr : meta ] ) * , pub $ name : ident < $ i : ty , $ o : ty > , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; ( $ ( # [ $ attr : meta ] ) * , pub $ name : ident < $ o : ty > , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; ( $ ( # [ $ attr : meta ] ) * , pub $ name : ident , $ submac : ident ! ( $ ( $ args : tt ) * ) ) => { ... }; }
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!(#[doc = "My Func\nRecognise abcd"], pub my_function, tag!("abcd")); // Multiple attributes can be passed if required named!(#[doc = "My Func"] #[inline(always)], pub my_function, tag!("abcd"));