pub fn generate_tag_traits(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
    let trait_defs: Vec<proc_macro2::TokenStream> = parse_macro_input!(input with Punctuated::<Expr, Token![,]>::parse_terminated) // items are separated by commas
        .iter()
        .map::<proc_macro2::TokenStream, _>(|syntax_branch| {
            if let Expr::Lit(expr_lit) = syntax_branch {
                // case 1: argument is exactly one literal, and we produce a trait including a simple getter method
                generate_getter_trait(expr_lit)
            } else if let Expr::Cast(assignment) = syntax_branch {
                // case 2: argument involves a conversion, and we produce a trait including a parsing method
                generate_parser_trait(assignment)
            } else {
                // using quote_spanned while throwing an error lets us specify which part of the expression should be underlined red
                quote_spanned!(syntax_branch.span()=> compile_error!("Invalid argument syntax. Arguments can have the form `<Tag Index String Literal>` or `<Tag Index String Literal> as <Type>`."))
            }
        })
        .collect();
    quote!(
        #(#trait_defs)*
    )
    .into()
}
/// Generates traits that contain a getter for an IRC tag, optionally parsed as an element of a supplied type. Multiple traits can be generated by supplying multiple arguments separated by commas.
/// Example: `generate_tag_parser_getter!("bits" as u64)` creates a trait `HasBitsTag<'a>` that includes a method with signature
/// `fn bits(&self) -> Option<ParsedTag<u64>>` that parses the "bits" token, if possible.
/// Example: `generate_tag_parser_getter!("user-name")` creates a trait `HasUserNameTag` that includes a method that returns the value stored in the "user-name" tag, with signature `fn user_name(&self) -> Option<&str>`.
/// # Panics
/// Panics if the token stream cannot be parsed into any expression.
Generates traits that contain a getter for an IRC tag, optionally parsed as an element of a supplied type. Multiple traits can be generated by supplying multiple arguments separated by commas.
Generates traits that contain a getter for an IRC tag optionally parsed as an element of a supplied type . Multiple traits can be generated by supplying multiple arguments separated by commas .
pub fn generate_tag_traits(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
    let trait_defs: Vec<proc_macro2::TokenStream> = parse_macro_input!(input with Punctuated::<Expr, Token![,]>::parse_terminated) // items are separated by commas
        .iter()
        .map::<proc_macro2::TokenStream, _>(|syntax_branch| {
            if let Expr::Lit(expr_lit) = syntax_branch {
                // case 1: argument is exactly one literal, and we produce a trait including a simple getter method
                generate_getter_trait(expr_lit)
            } else if let Expr::Cast(assignment) = syntax_branch {
                // case 2: argument involves a conversion, and we produce a trait including a parsing method
                generate_parser_trait(assignment)
            } else {
                // using quote_spanned while throwing an error lets us specify which part of the expression should be underlined red
                quote_spanned!(syntax_branch.span()=> compile_error!("Invalid argument syntax. Arguments can have the form `<Tag Index String Literal>` or `<Tag Index String Literal> as <Type>`."))
            }
        })
        .collect();
    quote!(
        #(#trait_defs)*
    )
    .into()
}
pub fn generate_tag_traits ( input : proc_macro :: TokenStream ) -> proc_macro :: TokenStream { let trait_defs : Vec < proc_macro2 :: TokenStream > = parse_macro_input ! ( input with Punctuated Expr Token [ ] parse_terminated ) // items are separated by commas . iter ( ) . map :: < proc_macro2 :: TokenStream , _ > ( | syntax_branch | { if let Expr :: Lit ( expr_lit ) = syntax_branch { // case 1: argument is exactly one literal, and we produce a trait including a simple getter method generate_getter_trait ( expr_lit ) } else if let Expr :: Cast ( assignment ) = syntax_branch { // case 2: argument involves a conversion, and we produce a trait including a parsing method generate_parser_trait ( assignment ) } else { // using quote_spanned while throwing an error lets us specify which part of the expression should be underlined red quote_spanned ! ( syntax_branch span ( ) compile_error ( " " ) ) } } ) . collect ( ) ; quote ! ( ( trait_defs ) ) . into ( ) }
Generates traits that contain a getter for an IRC tag, optionally parsed as an element of a supplied type.
Generates traits that contain a getter for an IRC tag optionally parsed as an element of a supplied type .
input
proc_macro::TokenStream
input
proc_macro::TokenStream
panics
Panics if the token stream cannot be parsed into any expression.
Panics if the token stream cannot be parsed into any expression .