From 3480d26c10f09f886de47f7f31096b4bc1303a41 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 14 Jul 2026 03:26:28 +0800 Subject: feat(picker): add `pick` method to start and extend flag chains --- mingling_picker/src/picker.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'mingling_picker/src/picker.rs') diff --git a/mingling_picker/src/picker.rs b/mingling_picker/src/picker.rs index ecf59b0..914d8b2 100644 --- a/mingling_picker/src/picker.rs +++ b/mingling_picker/src/picker.rs @@ -3,6 +3,8 @@ use std::ops::Index; mod patterns; pub use patterns::*; +use crate::{Pickable, PickerFlag, PickerResult}; + /// Picker, used to record all states of a parameter parsing /// /// Includes the following: @@ -222,6 +224,22 @@ pub trait IntoPicker<'a> { /// assert_eq!(args.len(), 2); /// ``` fn to_picker(self) -> Picker<'a>; + + /// Creates a `PickerPattern1` from the given flag for the `pick` method. + /// + /// This method converts the value into a `Picker` and starts a parameter + /// picking chain with one flag. The result is initially `Unparsed`. + fn pick(self, flag: &'a PickerFlag<'a, N>) -> PickerPattern1<'a, N> + where + Self: Sized, + N: Pickable + Default + Sized, + { + PickerPattern1 { + args: self.to_picker().args, + flag_1: flag, + result_1: PickerResult::Unparsed, + } + } } impl<'a> IntoPicker<'a> for &'a [&'a str] { -- cgit