aboutsummaryrefslogtreecommitdiff
path: root/mingling_picker/src/picker/patterns.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-14 02:17:33 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-14 02:17:33 +0800
commitde370df01a171b4fd910dfa9a067830acd1f9a3c (patch)
tree53350a4cdaa93437da6f06916ac371f82e79c57b /mingling_picker/src/picker/patterns.rs
parent62f6b476284da67efc55483a81b57f99a478702a (diff)
refactor(mingling_picker): move parse result out of requirement and into
pattern BREAKING CHANGE: `PickerRequirement` no longer stores a `PickerResult`. Parsed results are now held in the `PickerPattern` structs. The `result`, `result_mut`, `set_result`, `reset_result`, and `with_result` methods on `PickerRequirement` have been removed. The `Picker::pick` method is introduced to begin a pattern definition.
Diffstat (limited to 'mingling_picker/src/picker/patterns.rs')
-rw-r--r--mingling_picker/src/picker/patterns.rs22
1 files changed, 18 insertions, 4 deletions
diff --git a/mingling_picker/src/picker/patterns.rs b/mingling_picker/src/picker/patterns.rs
index 74a8cd8..80632d5 100644
--- a/mingling_picker/src/picker/patterns.rs
+++ b/mingling_picker/src/picker/patterns.rs
@@ -1,12 +1,26 @@
-use crate::{Pickable, PickerArguments, PickerRequirement};
+use crate::{Pickable, Picker, PickerArguments, PickerRequirement, PickerResult};
mingling_picker_macros::internal_repeat! (1..=32 => {
- pub struct PickerPattern$<'a, (Type$,)+>
- where (Type$: Pickable + Default,)+
+ pub struct PickerPattern$<'a, (T$,)+>
+ where (T$: Pickable + Default,)+
{
pub args: PickerArguments<'a>,
(
- pub require_$: PickerRequirement<'a, Type$>,
+ pub require_$: &'a PickerRequirement<'a, T$>,
+ pub result_$: PickerResult<T$>,
)+
}
});
+
+impl<'a> Picker<'a> {
+ pub fn pick<N>(self, req: &'a PickerRequirement<'a, N>) -> PickerPattern1<'a, N>
+ where
+ N: Pickable + Default,
+ {
+ PickerPattern1 {
+ args: self.args,
+ require_1: req,
+ result_1: PickerResult::Unparsed,
+ }
+ }
+}