From 0ddfcbd044aa2a35f716f8d9b18c056dd6ec46af Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 3 Aug 2026 14:46:37 +0800 Subject: refactor(picker): replace global picker functions with PickerHelper trait --- mingling/src/setups/picker/structural_renderer.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'mingling/src/setups/picker/structural_renderer.rs') diff --git a/mingling/src/setups/picker/structural_renderer.rs b/mingling/src/setups/picker/structural_renderer.rs index 1fa48fd..91848e4 100644 --- a/mingling/src/setups/picker/structural_renderer.rs +++ b/mingling/src/setups/picker/structural_renderer.rs @@ -1,9 +1,6 @@ use mingling_core::{Program, ProgramCollect, setup::ProgramSetup}; -use crate::{ - consts::RENDERER_ARG, - picker::{pick_global_argument, pick_global_flag}, -}; +use crate::{consts::RENDERER_ARG, picker::PickerHelper}; /// Sets up the structural renderer for the program: /// @@ -15,7 +12,7 @@ where C: ProgramCollect, { fn setup(self, program: &mut Program) { - if let Some(renderer) = pick_global_argument(program, &RENDERER_ARG) { + if let Some(renderer) = program.pick_argument(&RENDERER_ARG) { program.structural_renderer_name = renderer.into(); } } @@ -49,27 +46,27 @@ where { fn setup(self, program: &mut Program) { #[cfg(feature = "json_serde_fmt")] - if pick_global_flag(program, &crate::consts::JSON_FLAG) { + if program.pick_flag(&crate::consts::JSON_FLAG) { program.structural_renderer_name = crate::StructuralRendererSetting::Json; } #[cfg(feature = "json_serde_fmt")] - if pick_global_flag(program, &crate::consts::JSON_PRETTY_FLAG) { + if program.pick_flag(&crate::consts::JSON_PRETTY_FLAG) { program.structural_renderer_name = crate::StructuralRendererSetting::JsonPretty; } #[cfg(feature = "yaml_serde_fmt")] - if pick_global_flag(program, &crate::consts::YAML_FLAG) { + if program.pick_flag(&crate::consts::YAML_FLAG) { program.structural_renderer_name = crate::StructuralRendererSetting::Yaml; } #[cfg(feature = "toml_serde_fmt")] - if pick_global_flag(program, &crate::consts::TOML_FLAG) { + if program.pick_flag(&crate::consts::TOML_FLAG) { program.structural_renderer_name = crate::StructuralRendererSetting::Toml; } #[cfg(feature = "ron_serde_fmt")] - if pick_global_flag(program, &crate::consts::RON_FLAG) { + if program.pick_flag(&crate::consts::RON_FLAG) { program.structural_renderer_name = crate::StructuralRendererSetting::Ron; } #[cfg(feature = "ron_serde_fmt")] - if pick_global_flag(program, &crate::consts::RON_PRETTY_FLAG) { + if program.pick_flag(&crate::consts::RON_PRETTY_FLAG) { program.structural_renderer_name = crate::StructuralRendererSetting::RonPretty; } } -- cgit