From 2aa7bda3cb21ce6c052b82e08bcab79a625d04f2 Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Sun, 31 May 2026 02:42:52 +0800 Subject: Enhance code quality across the entire codebase --- mingling_core/src/program.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'mingling_core/src/program.rs') diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs index 912975d..2e861e4 100644 --- a/mingling_core/src/program.rs +++ b/mingling_core/src/program.rs @@ -70,6 +70,7 @@ where C: ProgramCollect, { /// Creates a new Program instance, initializing command-line arguments from the environment. + #[must_use] pub fn new() -> Self { #[cfg(not(windows))] return Self::new_with_args(env::args().collect::>()); @@ -96,8 +97,8 @@ where #[cfg(not(feature = "dispatch_tree"))] dispatcher: Vec::new(), - stdout_setting: Default::default(), - user_context: Default::default(), + stdout_setting: ProgramStdoutSetting::default(), + user_context: ProgramUserContext::default(), #[cfg(feature = "general_renderer")] general_renderer_name: GeneralRendererSetting::Disable, @@ -109,6 +110,10 @@ where } /// Returns a reference to the current program instance, if set. + /// + /// # Panics + /// + /// Panics if the program has not been initialized yet. pub fn this_program() -> &'static Program where C: 'static, @@ -123,6 +128,7 @@ where } /// Get all registered dispatcher names from the program + #[must_use] pub fn get_nodes( &'static self, ) -> Vec<(String, &'static (dyn Dispatcher + Send + Sync + 'static))> { @@ -130,11 +136,17 @@ where } /// Dynamically dispatch input arguments to registered entry types + /// + /// # Errors + /// + /// Returns `Err(ChainProcessError)` if the dispatch fails, + /// e.g., if no dispatcher is found for the given arguments. pub fn dispatch_args_dynamic( &'static self, args: impl Into, ) -> Result, ChainProcessError> { - match exec::dispatch_args_dynamic(self, &args.into().into()) { + let sv: Vec = args.into().into(); + match exec::dispatch_args_dynamic(self, &sv) { Ok(ok) => Ok(ok), Err(e) => Err(e.into()), } @@ -229,6 +241,7 @@ macro_rules! __dispatch_program_chains { /// Get all registered dispatcher names from the program #[allow(unused_variables)] +#[must_use] pub fn get_nodes>( program: &'static Program, ) -> Vec<(String, &'static (dyn Dispatcher + Send + Sync + 'static))> { -- cgit