From 9d491352d161ee629cc47459537344ba0ea4bb35 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 20 Jun 2026 01:11:25 +0800 Subject: Add shared `MockProgramCollect` and conditional `Groupped` bounds Extract duplicate `MockCollect` implementations into a reusable `MockProgramCollect` type. Conditionally require `Serialize` on the `Groupped` trait when the `general_renderer` feature is enabled. --- mingling_macros/src/dispatcher.rs | 1 + mingling_macros/src/lib.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'mingling_macros/src') diff --git a/mingling_macros/src/dispatcher.rs b/mingling_macros/src/dispatcher.rs index 7e973eb..6bf10f1 100644 --- a/mingling_macros/src/dispatcher.rs +++ b/mingling_macros/src/dispatcher.rs @@ -223,6 +223,7 @@ pub fn dispatcher(input: TokenStream) -> TokenStream { ::mingling::macros::node!(#command_name_str) } fn begin(&self, args: Vec) -> ::mingling::ChainProcess<#program_path> { + use ::mingling::Groupped; #pack::new(args).to_chain() } fn clone_dispatcher(&self) -> Box> { diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs index 408450a..9880cd6 100644 --- a/mingling_macros/src/lib.rs +++ b/mingling_macros/src/lib.rs @@ -480,7 +480,7 @@ pub fn route(input: TokenStream) -> TokenStream { #[proc_macro] pub fn empty_result(_input: TokenStream) -> TokenStream { let expanded = quote! { - crate::ResultEmpty::new(()).to_chain() + >::to_chain(crate::ResultEmpty::new(())) }; TokenStream::from(expanded) } @@ -1413,6 +1413,8 @@ pub fn program_comp_gen(input: TokenStream) -> TokenStream { #[doc(hidden)] #[::mingling::macros::chain(#name)] pub async fn __exec_completion(prev: CompletionContext) -> Next { + use ::mingling::Groupped; + let read_ctx = ::mingling::ShellContext::try_from(prev.inner); match read_ctx { Ok(ctx) => { @@ -1429,6 +1431,8 @@ pub fn program_comp_gen(input: TokenStream) -> TokenStream { #[doc(hidden)] #[::mingling::macros::chain(#name)] pub fn __exec_completion(prev: CompletionContext) -> Next { + use ::mingling::Groupped; + let read_ctx = ::mingling::ShellContext::try_from(prev.inner); match read_ctx { Ok(ctx) => { @@ -1452,6 +1456,7 @@ pub fn program_comp_gen(input: TokenStream) -> TokenStream { #[doc(hidden)] mod __internal_completion_mod { use super::#name; + use ::mingling::Groupped; ::mingling::macros::dispatcher!(#name, "__comp", CMDCompletion => CompletionContext); ::mingling::macros::pack!( #name, -- cgit