home · login to get plonkin'

proc macro attribute MetaNameValue parsing attempt

@uncenter.dev · 20d ago · rust · 22 loc · raw · 0 comments

1    let args =2        parse_macro_input!(args with Punctuated::<MetaNameValue, syn::Token![,]>::parse_terminated);34    let node_types_path: String = args5        .iter()6        .find(|attr| attr.path.is_ident("node_types_path"))7        .and_then(|option| {8            if let MetaNameValue {9                value:10                    Expr::Lit(syn::ExprLit {11                        lit: Lit::Str(value),12                        ..13                    }),14                ..15            } = option16            {17                Some(value.value())18            } else {19                None20            }21        })22        .expect("node_types_path must be a string literal");

login to post a comment