use syn::{
parse::{Parse, ParseStream},
Ident, Item, ItemFn, Visibility,
};
pub struct StructName {
pub vis: Visibility,
pub name: Ident,
}
impl Parse for StructName {
fn parse(input: ParseStream) -> syn::Result<Self> {
let parsed: Item = input.parse()?;
let func = match parsed {
Item::Fn(m) => m,
item => {
return Err(syn::Error::new_spanned(
item,
"The component attribute macro is only working for functions",
))
}
};
let ItemFn {
vis,
attrs: _,
sig,
block: _
} = func;
let name = sig.ident;
Ok(Self{
vis,
name
})
}
}