Trait 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§

Source

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

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for Expr

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for GenericParam

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for Lit

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for Visibility

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for Type

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for bool

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for char

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for f32

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for f64

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for i8

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for i16

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for i32

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for i64

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for isize

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for u8

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for u16

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for u32

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for u64

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for usize

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for String

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for Ident

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for Lifetime

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for LitBool

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for LitFloat

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for LitInt

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for LitStr

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Source§

impl MacroArg for Path

Source§

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

The None variant will only be generated if the argument is missing

Source§

fn parse_macro_arg(stream: ParseStream<'_>) -> Result<Self>

Implementors§