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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so 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>
Parses an optional MacroArg,
always returning the Some
variant
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