pub fn tag_nested_metas_iter<'f>(
    namespace_nested_metas_iter: impl Iterator<Item = Meta> + 'f,
    tag: &'f Path
) -> impl Iterator<Item = Meta> + 'f
Expand description

Returns an iterator over nested metas from #[namespace(tag(..))].

Parameters

  • namespace_nested_metas_iter: The #[namespace(..)] meta lists.
  • tag: The path() of the second-level attribute.

Examples

use proc_macro_roids::{namespace_nested_metas_iter, tag_nested_metas_iter};
use syn::{parse_quote, DeriveInput, Meta, 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 ns_lists = namespace_nested_metas_iter(&ast.attrs, &ns);
let nested_metas = tag_nested_metas_iter(ns_lists, &tag).collect::<Vec<Meta>>();

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