From c23c590330af83afb6e146bcd9b0a274b3689d22 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 17 Aug 2026 03:27:46 +0800 Subject: refactor!: remove Node type and simplify dispatcher macro syntax The `dispatcher!` macro no longer requires a `CMD*` dispatcher type argument; the dispatcher struct is now generated internally as `__Dispatcher{Pascal}`. The `Node` type, `node!` macro, and `Dispatcher::node()` / `clone_dispatcher()` methods are removed. --- mingling_macros/src/func/node.rs | 60 ---------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 mingling_macros/src/func/node.rs (limited to 'mingling_macros/src/func/node.rs') diff --git a/mingling_macros/src/func/node.rs b/mingling_macros/src/func/node.rs deleted file mode 100644 index 9963037..0000000 --- a/mingling_macros/src/func/node.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Doc Not Optimize -use just_fmt::kebab_case; -use proc_macro::TokenStream; -use proc_macro2::TokenStream as TokenStream2; -use quote::quote; -use syn::parse::{Parse, ParseStream}; -use syn::{LitStr, Result as SynResult}; - -/// Parses a string literal input for the node macro -struct NodeInput { - path: LitStr, -} - -impl Parse for NodeInput { - fn parse(input: ParseStream) -> SynResult { - Ok(Self { - path: input.parse()?, - }) - } -} - -pub(crate) fn node(input: TokenStream) -> TokenStream { - // Parse the input as a string literal - let input_parsed = syn::parse_macro_input!(input as NodeInput); - let path_str = input_parsed.path.value(); - - // If the input string is empty, return an empty Node - if path_str.is_empty() { - return quote! { - mingling::Node::default() - } - .into(); - } - - // Split the path by dots - let parts: Vec = path_str - .split('.') - .map(|s| { - if s.starts_with('_') { - s.to_string() - } else { - kebab_case!(s) - } - }) - .collect(); - - // Build the expression starting from Node::default() - let mut expr: TokenStream2 = quote! { - mingling::Node::default() - }; - - // Add .join() calls for each part of the path - for part in parts { - expr = quote! { - #expr.join(#part) - }; - } - - expr.into() -} -- cgit