aboutsummaryrefslogtreecommitdiff
path: root/arg_picker/src/picker
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-18 06:21:52 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-18 06:21:52 +0800
commit5fe4a4e40341aaa2b66fa1cf123d674f61d3e370 (patch)
tree15c2d1d4b1ee9aab1916b5d19a5bf765cf093250 /arg_picker/src/picker
parentd42665a0d223d2a8dbd278ac14632a55c5dbc246 (diff)
refactor(picker): extract pick_flag helper to reduce duplication
Diffstat (limited to 'arg_picker/src/picker')
-rw-r--r--arg_picker/src/picker/parse.rs8
-rw-r--r--arg_picker/src/picker/result.rs8
2 files changed, 10 insertions, 6 deletions
diff --git a/arg_picker/src/picker/parse.rs b/arg_picker/src/picker/parse.rs
index 366028b..9db5bd9 100644
--- a/arg_picker/src/picker/parse.rs
+++ b/arg_picker/src/picker/parse.rs
@@ -21,14 +21,16 @@ internal_repeat!(1..=32 => {
internal_repeat!(1..=32 => {
impl<'a, (T$,+), Route> PickerPattern$<'a, (T$,+), Route>
where (T$: Pickable<'a>,+) {
- /// Unwraps the result, panicking if a route was selected.
+ /// Unwraps the result, panicking if a route was selected or a required
+ /// value is missing.
///
/// # Panics
///
- /// Panics if a route was selected.
+ /// Panics if a route was selected, or if a required argument was not
+ /// provided by the user.
pub fn unwrap(self) -> ((T$,+)) {
let p = self.parse();
- ((p.v$.unwrap(),+))
+ ((p.v$.expect(concat!("missing required argument at position ", $)),+))
}
/// Returns the individual option values without checking the route.
diff --git a/arg_picker/src/picker/result.rs b/arg_picker/src/picker/result.rs
index 83ca2cd..2099825 100644
--- a/arg_picker/src/picker/result.rs
+++ b/arg_picker/src/picker/result.rs
@@ -21,13 +21,15 @@ internal_repeat!(1..=32 => {
internal_repeat!(1..=32 => {
impl<(T$,+), Route> PickerResult$<(T$,+), Route> {
- /// Unwraps the result, panicking if a route was selected.
+ /// Unwraps the result, panicking if a route was selected or a required
+ /// value is missing.
///
/// # Panics
///
- /// Panics if `self.route` is `Some(...)`.
+ /// Panics if `self.route` is `Some(...)`, or if a required argument was
+ /// not provided by the user.
pub fn unwrap(self) -> ((T$,+)) {
- ((self.v$.unwrap(),+))
+ ((self.v$.expect(concat!("missing required argument at position ", $)),+))
}
/// Returns the individual option values without checking the route.