From a9d5943939261e27e58bcf5cacbb618a0f63e999 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 10 Aug 2026 15:49:31 +0800 Subject: refactor(core): improve code style and public API clarity Replace bool-based settings with enums, refine visibility and signatures, and standardize `Self` usage across the crate. - Introduce `ErrorOutput`, `RenderOutput`, `PanicSilence`, `Verbosity`, `ColorOutput`, and `ProgressOutput` enums for clearer configuration semantics - Make `GlobalResources`, `ProgramCell`, and `split_input`/`split_input_string` public - Change hook info parameters to accept references and `split_input_string` to take `&str` - Apply `Self` shorthand throughout implementations and add `#[must_use]` attributes where appropriate - Enable strict clippy lints with targeted allowances --- mingling_core/src/program/once_exec.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'mingling_core/src/program/once_exec.rs') diff --git a/mingling_core/src/program/once_exec.rs b/mingling_core/src/program/once_exec.rs index 96723fd..18e06ef 100644 --- a/mingling_core/src/program/once_exec.rs +++ b/mingling_core/src/program/once_exec.rs @@ -21,7 +21,7 @@ where C: 'static + Send + Sync, { // Run hooks - self.run_hook_on_begin(crate::hook::HookBeginInfo {}); + self.run_hook_on_begin(&crate::hook::HookBeginInfo {}); self.args = self.args.iter().skip(1).cloned().collect(); @@ -43,11 +43,11 @@ where let program = THIS_PROGRAM .get_raw() .unwrap() - .downcast_ref::>() + .downcast_ref::() .unwrap(); #[cfg(not(feature = "async"))] - program.run_hook_exec_panic(crate::hook::HookPanicInfo { + program.run_hook_exec_panic(&crate::hook::HookPanicInfo { panic: &panic_payload, }); @@ -98,7 +98,7 @@ where // Read exit code // Render result - if stdout_setting.render_output { + if stdout_setting.render_output == crate::RenderOutput::Show { result.std_print(); } @@ -152,17 +152,17 @@ where pub(crate) fn exec_wrapper(self, f: F) -> R where C: 'static + Send + Sync, - F: FnOnce(&'static Program) -> R + Send + Sync, + F: FnOnce(&'static Self) -> R + Send + Sync, { THIS_PROGRAM.set(Box::new(self)); let program = THIS_PROGRAM .get_raw() .unwrap() - .downcast_ref::>() + .downcast_ref::() .unwrap(); #[cfg(not(panic = "abort"))] - if program.stdout_setting.silence_panic { + if program.stdout_setting.silence_panic == super::PanicSilence::Silence { std::panic::set_hook(Box::new(|_| {})); } -- cgit