use std::vec::IntoIter;
use syn::{
ext::IdentExt,
parse::{
Parse,
ParseStream,
},
NestedMeta,
};
pub struct AttributeArgs(Vec<NestedMeta>);
impl Parse for AttributeArgs {
fn parse(input: ParseStream) -> syn::Result<Self> {
let mut attrs = Vec::new();
while input.peek(syn::Ident::peek_any) {
attrs.push(input.parse()?);
if input.is_empty() {
break
}
let _: syn::token::Comma = input.parse()?;
}
Ok(AttributeArgs(attrs))
}
}
impl IntoIterator for AttributeArgs {
type Item = NestedMeta;
type IntoIter = IntoIter<NestedMeta>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
impl std::ops::Deref for AttributeArgs {
type Target = Vec<NestedMeta>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl std::ops::DerefMut for AttributeArgs {
fn deref_mut(&mut self) -> &mut Vec<NestedMeta> {
&mut self.0
}
}