From 5b8be21e09165ba5098fde378369925fc8dacb3f Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 20 Jun 2026 01:31:09 +0800 Subject: Remove unnecessary module wrapping for MockProgramCollect --- mingling_core/src/program/collection/mock.rs | 178 +++++++++++++-------------- 1 file changed, 87 insertions(+), 91 deletions(-) (limited to 'mingling_core/src') diff --git a/mingling_core/src/program/collection/mock.rs b/mingling_core/src/program/collection/mock.rs index e1b3aa4..caef804 100644 --- a/mingling_core/src/program/collection/mock.rs +++ b/mingling_core/src/program/collection/mock.rs @@ -1,105 +1,101 @@ -pub use mock::*; +#[cfg(feature = "async")] +use std::pin::Pin; -mod mock { - #[cfg(feature = "async")] - use std::pin::Pin; +#[cfg(feature = "dispatch_tree")] +use crate::Dispatcher; + +use crate::{AnyOutput, ChainProcess, Groupped, ProgramCollect, RenderResult}; + +#[cfg(feature = "general_renderer")] +use crate::{GeneralRendererSetting, error::GeneralRendererSerializeError}; + +#[cfg(feature = "comp")] +use crate::{ShellContext, Suggest}; + +#[cfg(feature = "general_renderer")] +use serde::Serialize; + +#[cfg_attr(feature = "general_renderer", derive(Serialize))] +#[allow(unused)] +pub enum MockProgramCollect { + Foo, + Bar, +} + +impl Groupped for MockProgramCollect { + fn member_id() -> MockProgramCollect { + MockProgramCollect::Foo + } +} + +impl ProgramCollect for MockProgramCollect { + type Enum = MockProgramCollect; + type ErrorDispatcherNotFound = MockProgramCollect; + type ErrorRendererNotFound = MockProgramCollect; + type ResultEmpty = MockProgramCollect; #[cfg(feature = "dispatch_tree")] - use crate::Dispatcher; + fn dispatch_args_trie( + _raw: &[String], + ) -> Result, crate::error::ProgramInternalExecuteError> { + unreachable!() + } - use crate::{AnyOutput, ChainProcess, Groupped, ProgramCollect, RenderResult}; + #[cfg(feature = "dispatch_tree")] + fn get_nodes() -> Vec<(String, &'static (dyn Dispatcher + Send + Sync))> { + unreachable!() + } - #[cfg(feature = "general_renderer")] - use crate::{GeneralRendererSetting, error::GeneralRendererSerializeError}; + fn build_renderer_not_found(_member_id: Self::Enum) -> AnyOutput { + unreachable!() + } - #[cfg(feature = "comp")] - use crate::{ShellContext, Suggest}; + fn build_dispatcher_not_found(_args: Vec) -> AnyOutput { + unreachable!() + } - #[cfg(feature = "general_renderer")] - use serde::Serialize; + fn build_empty_result() -> AnyOutput { + unreachable!() + } + + fn render(_any: AnyOutput, _r: &mut RenderResult) { + unreachable!() + } + + fn render_help(_any: AnyOutput, _r: &mut RenderResult) { + unreachable!() + } + + #[cfg(feature = "async")] + fn do_chain( + _any: AnyOutput, + ) -> Pin> + Send>> { + unreachable!() + } + + #[cfg(not(feature = "async"))] + fn do_chain(_any: AnyOutput) -> ChainProcess { + unreachable!() + } - #[cfg_attr(feature = "general_renderer", derive(Serialize))] - #[allow(unused)] - pub enum MockProgramCollect { - Foo, - Bar, + #[cfg(feature = "comp")] + fn do_comp(_any: &AnyOutput, _ctx: &ShellContext) -> Suggest { + unreachable!() + } + + fn has_renderer(_any: &AnyOutput) -> bool { + unreachable!() } - impl Groupped for MockProgramCollect { - fn member_id() -> MockProgramCollect { - MockProgramCollect::Foo - } + fn has_chain(_any: &AnyOutput) -> bool { + unreachable!() } - impl ProgramCollect for MockProgramCollect { - type Enum = MockProgramCollect; - type ErrorDispatcherNotFound = MockProgramCollect; - type ErrorRendererNotFound = MockProgramCollect; - type ResultEmpty = MockProgramCollect; - - #[cfg(feature = "dispatch_tree")] - fn dispatch_args_trie( - _raw: &[String], - ) -> Result, crate::error::ProgramInternalExecuteError> { - unreachable!() - } - - #[cfg(feature = "dispatch_tree")] - fn get_nodes() -> Vec<(String, &'static (dyn Dispatcher + Send + Sync))> { - unreachable!() - } - - fn build_renderer_not_found(_member_id: Self::Enum) -> AnyOutput { - unreachable!() - } - - fn build_dispatcher_not_found(_args: Vec) -> AnyOutput { - unreachable!() - } - - fn build_empty_result() -> AnyOutput { - unreachable!() - } - - fn render(_any: AnyOutput, _r: &mut RenderResult) { - unreachable!() - } - - fn render_help(_any: AnyOutput, _r: &mut RenderResult) { - unreachable!() - } - - #[cfg(feature = "async")] - fn do_chain( - _any: AnyOutput, - ) -> Pin> + Send>> { - unreachable!() - } - - #[cfg(not(feature = "async"))] - fn do_chain(_any: AnyOutput) -> ChainProcess { - unreachable!() - } - - #[cfg(feature = "comp")] - fn do_comp(_any: &AnyOutput, _ctx: &ShellContext) -> Suggest { - unreachable!() - } - - fn has_renderer(_any: &AnyOutput) -> bool { - unreachable!() - } - - fn has_chain(_any: &AnyOutput) -> bool { - unreachable!() - } - - #[cfg(feature = "general_renderer")] - fn general_render( - _any: AnyOutput, - _setting: &GeneralRendererSetting, - ) -> Result { - unreachable!() - } + #[cfg(feature = "general_renderer")] + fn general_render( + _any: AnyOutput, + _setting: &GeneralRendererSetting, + ) -> Result { + unreachable!() } } -- cgit