diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-15 19:31:23 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-15 19:33:45 +0800 |
| commit | 8b2bbdef88f47838ed0326f5c9cf86bac84babde (patch) | |
| tree | cab7e7d492e4778a8084919459e0e8f40cc0827f /mingling_picker/src/builtin/pick_bool.rs | |
| parent | 5894aa72a8e63f8b6d095678fe58e88fd64836a1 (diff) | |
feat(picker): add builtin bool pickable and parselib matcher framework
Add `Pickable` implementation for `bool` and the supporting `Matcher`
trait
with utility functions for argument matching. Expose `pickable_needed`
and
`matcher_needed` modules for downstream trait implementors.
Diffstat (limited to 'mingling_picker/src/builtin/pick_bool.rs')
| -rw-r--r-- | mingling_picker/src/builtin/pick_bool.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mingling_picker/src/builtin/pick_bool.rs b/mingling_picker/src/builtin/pick_bool.rs new file mode 100644 index 0000000..ad93a83 --- /dev/null +++ b/mingling_picker/src/builtin/pick_bool.rs @@ -0,0 +1,15 @@ +use crate::{parselib::Matcher, pickable_needed::*}; + +impl<'a> Pickable<'a> for bool { + fn get_attr(_: &'a PickerFlag<'a, Self>) -> PickerFlagAttr { + PickerFlagAttr::Flag + } + + fn tag(ctx: TagPhaseContext) -> Vec<usize> { + <bool as Matcher>::match_all(ctx.into()) + } + + fn pick(raw_strs: &[&str]) -> PickerArgResult<Self> { + PickerArgResult::Parsed(!raw_strs.is_empty()) + } +} |
