fn generate_parser_trait(assignment: &syn::ExprCast) -> proc_macro2::TokenStream {
    // destructure assignment as Expr::Lit
    let expr: &syn::ExprLit = match assignment.expr.unbox_ref() {
        Expr::Lit(x) => x,
        // using quote_spanned while throwing an error lets us specify which part of the expression should be underlined red
        _ => {
            return quote_spanned!(assignment.span()=> compile_error!("Each argument has to begin with a string literal specifying the tag index."))
        }
    };

    // destructure expr as Lit::Str
    let tag_index: &syn::LitStr = match &expr.lit {
        Lit::Str(x) => x,
        _ => {
            return quote_spanned!(expr.span()=> compile_error!("Each argument has to begin with a string literal specifying the tag index."))
        }
    };

    let parsed_type: Type = *assignment.ty.clone();
    let fn_name = tag_index.value().to_snake_case().to_ident();

    let fn_stream = quote! (
        fn #fn_name(&'a self) -> std::option::Option<crate::irc::tags::ParsedTag<#parsed_type>>{
            self.tags().get_parsed(#tag_index)
        }
    );

    wrap_in_trait(&fn_stream, tag_index)
}
/// Takes an individual argument that consists of an assignment with 'as', and returns the corresponding parser function.
Takes an individual argument that consists of an assignment with 'as', and returns the corresponding parser function.
Takes an individual argument that consists of an assignment with ' as ' and returns the corresponding parser function .
fn generate_parser_trait(assignment: &syn::ExprCast) -> proc_macro2::TokenStream {
    // destructure assignment as Expr::Lit
    let expr: &syn::ExprLit = match assignment.expr.unbox_ref() {
        Expr::Lit(x) => x,
        // using quote_spanned while throwing an error lets us specify which part of the expression should be underlined red
        _ => {
            return quote_spanned!(assignment.span()=> compile_error!("Each argument has to begin with a string literal specifying the tag index."))
        }
    };
    // destructure expr as Lit::Str
    let tag_index: &syn::LitStr = match &expr.lit {
        Lit::Str(x) => x,
        _ => {
            return quote_spanned!(expr.span()=> compile_error!("Each argument has to begin with a string literal specifying the tag index."))
        }
    };
    let parsed_type: Type = *assignment.ty.clone();
    let fn_name = tag_index.value().to_snake_case().to_ident();
    let fn_stream = quote! (
        fn #fn_name(&'a self) -> std::option::Option<crate::irc::tags::ParsedTag<#parsed_type>>{
            self.tags().get_parsed(#tag_index)
        }
    );
    wrap_in_trait(&fn_stream, tag_index)
}
fn generate_parser_trait ( assignment : & syn :: ExprCast ) -> proc_macro2 :: TokenStream { // destructure assignment as Expr::Lit let expr : & syn :: ExprLit = match assignment . expr . unbox_ref ( ) { Expr :: Lit ( x ) => x , // using quote_spanned while throwing an error lets us specify which part of the expression should be underlined red _ => { return quote_spanned ! ( assignment span ( ) compile_error ( " " ) ) } } ; // destructure expr as Lit::Str let tag_index : & syn :: LitStr = match & expr . lit { Lit :: Str ( x ) => x , _ => { return quote_spanned ! ( expr span ( ) compile_error ( " " ) ) } } ; let parsed_type : Type = * assignment . ty . clone ( ) ; let fn_name = tag_index . value ( ) . to_snake_case ( ) . to_ident ( ) ; let fn_stream = quote ! ( fn fn_name ( ' a self ) std option Option crate irc tags ParsedTag parsed_type { self tags ( ) get_parsed ( tag_index ) } ) ; wrap_in_trait ( & fn_stream , tag_index ) }
Takes an individual argument that consists of an assignment with 'as', and returns the corresponding parser function.
Takes an individual argument that consists of an assignment with ' as ' and returns the corresponding parser function .
assignment
&syn::ExprCast
assignment
&syn::ExprCast