proc: allow implementing #[command] over more complex types

This commit is contained in:
🪞👃🪞 2025-05-18 18:31:40 +03:00
parent 921378b6db
commit 7ddbace030
2 changed files with 3 additions and 3 deletions

View file

@ -10,7 +10,7 @@ pub(crate) use proc_macro2::{
TokenStream as TokenStream2, Ident, Span, Punct, Group, Delimiter, Spacing::* TokenStream as TokenStream2, Ident, Span, Punct, Group, Delimiter, Spacing::*
}; };
pub(crate) use syn::{ pub(crate) use syn::{
parse_macro_input, ImplItem, ImplItemFn, LitStr, Type, parse_macro_input, ImplItem, ImplItemFn, LitStr, Type, TypePath,
ItemImpl, ReturnType, Signature, FnArg, Pat, PatType, PatIdent, ItemImpl, ReturnType, Signature, FnArg, Pat, PatType, PatIdent,
parse::{Parse, ParseStream, Result}, parse::{Parse, ParseStream, Result},
}; };

View file

@ -4,7 +4,7 @@ use crate::*;
pub(crate) struct CommandDef(pub(crate) CommandMeta, pub(crate) CommandImpl); pub(crate) struct CommandDef(pub(crate) CommandMeta, pub(crate) CommandImpl);
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub(crate) struct CommandMeta(Ident); pub(crate) struct CommandMeta(TypePath);
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub(crate) struct CommandImpl(ItemImpl, BTreeMap<Arc<str>, CommandArm>); pub(crate) struct CommandImpl(ItemImpl, BTreeMap<Arc<str>, CommandArm>);
@ -14,7 +14,7 @@ struct CommandArm(Ident, Vec<FnArg>, #[allow(unused)] ReturnType);
impl Parse for CommandMeta { impl Parse for CommandMeta {
fn parse (input: ParseStream) -> Result<Self> { fn parse (input: ParseStream) -> Result<Self> {
Ok(Self(input.parse::<Ident>()?)) Ok(Self(input.parse()?))
} }
} }