Closed niuhuan closed 1 year ago
I want parsing recursive like this ”any“,”all” proc content. Is there a simpler tool or example?
(command is convert fn to trait struct, like rocket get/post macros)
// get name content #[event(command("hello {name}"))] async fn hello( name: Option<String>) -> anyhow::Result<bool> { if name.is_none() { return Ok(false); } Ok(true) } // all , any #[event(all(command("hello {name}", filter = "i_am_filter")))] async fn hello( name: Option<String>) -> anyhow::Result<bool> { if name.is_none() && name.unwrap().start_with("123") { return Ok(false); } event.send_message_to_source(format!("hello {}", name.unwrap()).parse_message_chain()).await.unwrap(); Ok(true) } async fn i_am_filter( name: Option<String>) -> anyhow::Result<bool> { if name.is_none() { return Ok(false); } // do some Ok(true) } #[event(regexp("^123$"))]
#[proc_macro_error] #[proc_macro_attribute] pub fn event(args: TokenStream, input: TokenStream) -> TokenStream { let attrs = parse_macro_input!(args as syn::AttributeArgs); }
I want parsing recursive like this ”any“,”all” proc content. Is there a simpler tool or example?
(command is convert fn to trait struct, like rocket get/post macros)