pub fn tag_parameters(
    attrs: &[Attribute],
    namespace: &Path,
    tag: &Path
) -> Vec<Meta>
Expand description

Returns the parameters from #[namespace(tag(param1, param2, ..))].

Parameters

  • attrs: Attributes of the item to inspect.
  • namespace: The path() of the first-level attribute.
  • tag: The path() of the second-level attribute.

Examples

use proc_macro_roids::tag_parameters;
use syn::{parse_quote, DeriveInput, Meta, MetaNameValue, Path};

let ast: DeriveInput = parse_quote! {
    #[namespace(tag(One))]
    #[namespace(tag(two = ""))]
    pub struct MyEnum;
};

let ns: Path = parse_quote!(namespace);
let tag: Path = parse_quote!(tag);
let tag_parameters = tag_parameters(&ast.attrs, &ns, &tag);

let meta_one: Path = parse_quote!(One);
let param_one = Meta::Path(meta_one);
let meta_two: MetaNameValue = parse_quote!(two = "");
let param_two = Meta::NameValue(meta_two);
assert_eq!(vec![param_one, param_two], tag_parameters);