aboutsummaryrefslogtreecommitdiff
path: root/mingling/src/parser
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-17 04:04:11 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-17 04:04:11 +0800
commitdc9d5ea0026a6cb6bb477d5db8e9190a79ecb337 (patch)
treefffa1630946e8299e25f805955cc3baa0479be0d /mingling/src/parser
parentb9f208deed7b8e012fbcd84202e2fb1d5eb8eeb9 (diff)
docs: add module-level documentation and improve doc comments
Diffstat (limited to 'mingling/src/parser')
-rw-r--r--mingling/src/parser/picker.rs7
-rw-r--r--mingling/src/parser/picker/bools.rs12
2 files changed, 19 insertions, 0 deletions
diff --git a/mingling/src/parser/picker.rs b/mingling/src/parser/picker.rs
index 21ba9a6..601cd3f 100644
--- a/mingling/src/parser/picker.rs
+++ b/mingling/src/parser/picker.rs
@@ -722,6 +722,13 @@ impl_pick_with_route_next! { PickWithRoute9 PickWithRoute10 val_10 T1 val_1, T2
impl_pick_with_route_next! { PickWithRoute10 PickWithRoute11 val_11 T1 val_1, T2 val_2, T3 val_3, T4 val_4, T5 val_5, T6 val_6, T7 val_7, T8 val_8, T9 val_9, T10 val_10 }
impl_pick_with_route_next! { PickWithRoute11 PickWithRoute12 val_12 T1 val_1, T2 val_2, T3 val_3, T4 val_4, T5 val_5, T6 val_6, T7 val_7, T8 val_8, T9 val_9, T10 val_10, T11 val_11 }
+/// Trait for types that can be used with `Pickable` to extract enum values from command-line arguments.
+///
+/// This trait combines `EnumTag` (for building an enum variant from a string name) and `Default`
+/// (for providing a fallback value when the flag is not present).
+///
+/// Types implementing this trait can be used with `Picker::pick`, `Picker::pick_or_route`, and
+/// the chaining `.pick()` methods to extract and parse enum values from command-line arguments.
pub trait PickableEnum: EnumTag + Default {}
impl<T> Pickable for T
diff --git a/mingling/src/parser/picker/bools.rs b/mingling/src/parser/picker/bools.rs
index ede8812..0525c52 100644
--- a/mingling/src/parser/picker/bools.rs
+++ b/mingling/src/parser/picker/bools.rs
@@ -1,9 +1,15 @@
use crate::parser::Pickable;
+/// Represents a boolean-like value with `Yes` and `No` variants.
+///
+/// `Yes` can be parsed from command-line arguments using positive keywords such as `"y"` or `"yes"`,
+/// and defaults to `No`.
#[derive(Debug, Default)]
#[repr(u8)]
pub enum Yes {
+ /// The affirmative/positive variant.
Yes,
+ /// The negative/default variant.
#[default]
No,
}
@@ -57,10 +63,16 @@ impl Pickable for Yes {
}
}
+/// Represents a boolean-like value with `True` and `False` variants.
+///
+/// `True` can be parsed from command-line arguments using positive keywords such as `"t"` or `"true"`,
+/// and defaults to `False`.
#[derive(Debug, Default)]
#[repr(u8)]
pub enum True {
+ /// The affirmative/positive variant.
True,
+ /// The negative/default variant.
#[default]
False,
}