From 9c8f5c8d60f3066fec8a1573aa3f5673e0b2ecb8 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 3 Aug 2026 13:36:13 +0800 Subject: chore!: rename ErrorDispatcherNotFound to EntryFallback Rename the internal fallback type and its associated `ProgramCollect` plumbing from `ErrorDispatcherNotFound`/`build_dispatcher_not_found` to `EntryFallback`/`build_entry_fallback`, along with the generated enum variant and pack type. Update all documentation, examples, and tests accordingly. --- mingling_macros/src/func/program_fallback_gen.rs | 2 +- mingling_macros/src/func/program_final_gen.rs | 6 +++--- mingling_macros/src/lib.rs | 12 ++++++------ mingling_macros/src/systems/dispatch_tree_gen.rs | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'mingling_macros') diff --git a/mingling_macros/src/func/program_fallback_gen.rs b/mingling_macros/src/func/program_fallback_gen.rs index 3d095e5..93d8616 100644 --- a/mingling_macros/src/func/program_fallback_gen.rs +++ b/mingling_macros/src/func/program_fallback_gen.rs @@ -16,7 +16,7 @@ pub(crate) fn program_fallback_gen_impl(_input: TokenStream) -> TokenStream { let expanded = quote! { ::mingling::macros::pack!(ErrorRendererNotFound = String); - ::mingling::macros::pack!(ErrorDispatcherNotFound = Vec); + ::mingling::macros::pack!(EntryFallback = Vec); #pack_empty }; TokenStream::from(expanded) diff --git a/mingling_macros/src/func/program_final_gen.rs b/mingling_macros/src/func/program_final_gen.rs index 0eed1db..e8545f4 100644 --- a/mingling_macros/src/func/program_final_gen.rs +++ b/mingling_macros/src/func/program_final_gen.rs @@ -298,15 +298,15 @@ pub(crate) fn program_final_gen_impl(_input: TokenStream) -> TokenStream { impl ::mingling::ProgramCollect for #name { type Enum = #name; - type ErrorDispatcherNotFound = ErrorDispatcherNotFound; + type EntryFallback = EntryFallback; type ErrorRendererNotFound = ErrorRendererNotFound; type ResultEmpty = ResultEmpty; fn build_renderer_not_found(member_id: Self::Enum) -> ::mingling::AnyOutput { ::mingling::AnyOutput::new(ErrorRendererNotFound::new(member_id.to_string())) } - fn build_dispatcher_not_found(args: Vec) -> ::mingling::AnyOutput { - ::mingling::AnyOutput::new(ErrorDispatcherNotFound::new(args)) + fn build_entry_fallback(args: Vec) -> ::mingling::AnyOutput { + ::mingling::AnyOutput::new(EntryFallback::new(args)) } fn build_empty_result() -> ::mingling::AnyOutput { ::mingling::AnyOutput::new(ResultEmpty) diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs index b6656da..c955e36 100644 --- a/mingling_macros/src/lib.rs +++ b/mingling_macros/src/lib.rs @@ -36,7 +36,7 @@ //! │ V │ //! │ Reads all registries → generates ThisProgram with: │ //! │ • ProgramCollect impl (dispatch/render/chain dispatch tree) │ -//! │ • Fallback types (ErrorDispatcherNotFound, etc.) │ +//! │ • Fallback types (EntryFallback, etc.) │ //! │ • Completion logic (if `comp` feature enabled) │ //! └──────────────────────────────────────────────────────────────────┘ //! ``` @@ -120,8 +120,8 @@ //! ```rust,ignore //! // Example of what gen_program! generates (simplified): //! impl ProgramCollect for ThisProgram { -//! fn build_dispatcher_not_found(args: Vec) -> AnyOutput { -//! AnyOutput::new(ErrorDispatcherNotFound::new(args)) +//! fn build_entry_fallback(args: Vec) -> AnyOutput { +//! AnyOutput::new(EntryFallback::new(args)) //! } //! fn has_chain(any: &AnyOutput) -> bool { //! match any.member_id() { @@ -978,11 +978,11 @@ pub fn chain(attr: TokenStream, item: TokenStream) -> TokenStream { /// The macros `gen_program!` automatically generates two fallback types that /// you can provide renderers for: /// - `ErrorRendererNotFound` — triggered when no matching renderer is found -/// - `ErrorDispatcherNotFound` — triggered when no matching dispatcher is found +/// - `EntryFallback` — triggered when no matching dispatcher is found /// /// ```rust,ignore /// #[renderer] -/// fn fallback_dispatcher_not_found(prev: ErrorDispatcherNotFound) -> RenderResult { +/// fn fallback_dispatcher_not_found(prev: EntryFallback) -> RenderResult { /// let mut result = RenderResult::new(); /// writeln!(result, "Unknown command: {}", prev.join(", ")); /// result @@ -1819,7 +1819,7 @@ pub fn derive_grouped_serialize(input: TokenStream) -> TokenStream { /// 1. **`pub type Next = ChainProcess`** — A convenience type alias /// for use in chain function return types. /// 2. **`program_comp_gen!(...)`** (with `comp` feature) — Generates completion infrastructure. -/// 3. **`program_fallback_gen!(...)`** — Generates `ErrorRendererNotFound` and `ErrorDispatcherNotFound` types. +/// 3. **`program_fallback_gen!(...)`** — Generates `ErrorRendererNotFound` and `EntryFallback` types. /// 4. **`program_final_gen!(...)`** — Generates the program enum with: /// - An enum with all packed types as variants /// - `Display` implementation for the enum diff --git a/mingling_macros/src/systems/dispatch_tree_gen.rs b/mingling_macros/src/systems/dispatch_tree_gen.rs index fe44a49..8e3660c 100644 --- a/mingling_macros/src/systems/dispatch_tree_gen.rs +++ b/mingling_macros/src/systems/dispatch_tree_gen.rs @@ -61,7 +61,7 @@ pub(crate) fn gen_dispatch_args_trie(entries: &[(String, String, String)]) -> To fn build_dispatch_body(nodes: &[(String, String)], depth: usize) -> TokenStream { if nodes.is_empty() { return quote! { - return Ok(Self::build_dispatcher_not_found(raw.to_vec())); + return Ok(Self::build_entry_fallback(raw.to_vec())); }; } @@ -113,7 +113,7 @@ fn build_dispatch_body(nodes: &[(String, String)], depth: usize) -> TokenStream arms.push(quote! { Some(#ch_char) => { #arm - return Ok(Self::build_dispatcher_not_found(raw.to_vec())); + return Ok(Self::build_entry_fallback(raw.to_vec())); } }); } else { @@ -135,7 +135,7 @@ fn build_dispatch_body(nodes: &[(String, String)], depth: usize) -> TokenStream let match_body = quote! { match raw_chars.nth(0) { #(#arms)* - _ => return Ok(Self::build_dispatcher_not_found(raw.to_vec())), + _ => return Ok(Self::build_entry_fallback(raw.to_vec())), } }; quote! { @@ -145,17 +145,17 @@ fn build_dispatch_body(nodes: &[(String, String)], depth: usize) -> TokenStream } else if !exact_checks.is_empty() { quote! { #(#exact_checks)* - return Ok(Self::build_dispatcher_not_found(raw.to_vec())); + return Ok(Self::build_entry_fallback(raw.to_vec())); } } else if arms.is_empty() { quote! { - return Ok(Self::build_dispatcher_not_found(raw.to_vec())); + return Ok(Self::build_entry_fallback(raw.to_vec())); } } else { quote! { match raw_chars.nth(0) { #(#arms)* - _ => return Ok(Self::build_dispatcher_not_found(raw.to_vec())), + _ => return Ok(Self::build_entry_fallback(raw.to_vec())), } } } -- cgit