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§

source

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

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§