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/flag.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'mingling_core/src/program/flag.rs') diff --git a/mingling_core/src/program/flag.rs b/mingling_core/src/program/flag.rs index 6cf126d..81d83e6 100644 --- a/mingling_core/src/program/flag.rs +++ b/mingling_core/src/program/flag.rs @@ -44,27 +44,27 @@ pub struct Flag { vec: Vec<&'static str>, } -impl From<&Flag> for Flag { - fn from(value: &Flag) -> Self { +impl From<&Self> for Flag { + fn from(value: &Self) -> Self { value.clone() } } impl From<()> for Flag { fn from((): ()) -> Self { - Flag { vec: vec![] } + Self { vec: vec![] } } } impl From<&'static str> for Flag { fn from(s: &'static str) -> Self { - Flag { vec: vec![s] } + Self { vec: vec![s] } } } impl From<&'static [&'static str]> for Flag { fn from(slice: &'static [&'static str]) -> Self { - Flag { + Self { vec: slice.to_vec(), } } @@ -72,7 +72,7 @@ impl From<&'static [&'static str]> for Flag { impl From<[&'static str; N]> for Flag { fn from(slice: [&'static str; N]) -> Self { - Flag { + Self { vec: slice.to_vec(), } } @@ -80,7 +80,7 @@ impl From<[&'static str; N]> for Flag { impl From<&'static [&'static str; N]> for Flag { fn from(slice: &'static [&'static str; N]) -> Self { - Flag { + Self { vec: slice.to_vec(), } } @@ -169,7 +169,7 @@ where /// Registers a global argument (with value) and its handler. pub fn global_argument(&mut self, arguments: A, mut do_fn: F) where - F: FnMut(&mut Program, String), + F: FnMut(&mut Self, String), A: Into, { let flag = arguments.into(); @@ -185,7 +185,7 @@ where /// Registers a global flag (boolean) and its handler. pub fn global_flag(&mut self, flag: A, mut do_fn: F) where - F: FnMut(&mut Program), + F: FnMut(&mut Self), A: Into, { let flag = flag.into(); -- cgit