pub fn namespace_nested_metas_iter<'f>(
    attrs: &'f [Attribute],
    namespace: &'f Path
) -> impl Iterator<Item = Meta> + 'f
Expand description

Returns the meta lists of the form: #[namespace(..)].

Each meta_list is a namespace(..) meta item.

Parameters

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

Examples

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

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

let ns: Path = parse_quote!(namespace);
let nested_metas = namespace_nested_metas_iter(&ast.attrs, &ns).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);