Trait proc_macro_kwargs::parse::MacroArg
source · pub trait MacroArg: Sized {
// Required method
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>;
}
Expand description
A type that can be parsed as an argument to a macro.
This is often implemented by delegating to syn’s Parse.
However, sometimes it can behave differently.
For example, nested MacroKeywordArgs
require surrounding braces {}
when parsed as a MacroArg
,
but not when parsed via syn’s Parse.
This gives the effect of requiring braces when nested (as a MacroArg), but not at the top level (via syn’s Parse).
Required Methods§
sourcefn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
Parse the argument to the macro
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl MacroArg for Meta
impl MacroArg for Meta
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for Expr
impl MacroArg for Expr
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for GenericParam
impl MacroArg for GenericParam
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for Lit
impl MacroArg for Lit
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for Visibility
impl MacroArg for Visibility
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for Type
impl MacroArg for Type
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for bool
impl MacroArg for bool
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for char
impl MacroArg for char
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for f32
impl MacroArg for f32
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for f64
impl MacroArg for f64
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for i8
impl MacroArg for i8
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for i16
impl MacroArg for i16
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for i32
impl MacroArg for i32
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for i64
impl MacroArg for i64
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for isize
impl MacroArg for isize
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for u8
impl MacroArg for u8
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for u16
impl MacroArg for u16
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for u32
impl MacroArg for u32
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for u64
impl MacroArg for u64
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for usize
impl MacroArg for usize
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for String
impl MacroArg for String
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for Ident
impl MacroArg for Ident
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for Lifetime
impl MacroArg for Lifetime
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for LitBool
impl MacroArg for LitBool
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for LitFloat
impl MacroArg for LitFloat
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for LitInt
impl MacroArg for LitInt
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for LitStr
impl MacroArg for LitStr
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl MacroArg for Path
impl MacroArg for Path
fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>
source§impl<T: MacroArg> MacroArg for Option<T>
impl<T: MacroArg> MacroArg for Option<T>
Parses an optional MacroArg,
always returning the Some
variant
The None
variant will only be generated
if the argument is missing