aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-19 00:35:09 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-19 00:35:09 +0800
commit501eb14dfca05813fa7a16f13f2efd9ba2b8c923 (patch)
tree2c1c7a58c50a2ac07a7eb9e3d698c33442430aea
parent5e460470f6ea2ce31a403b6e936ec2fe8f45312a (diff)
docs: add doc comments for Picker, AsPicker, and ProgramSetup traits
-rw-r--r--mingling/src/parser/picker.rs4
-rw-r--r--mingling/src/setups.rs4
-rw-r--r--mingling_core/src/program/setup.rs17
3 files changed, 25 insertions, 0 deletions
diff --git a/mingling/src/parser/picker.rs b/mingling/src/parser/picker.rs
index 601cd3f..ca4561c 100644
--- a/mingling/src/parser/picker.rs
+++ b/mingling/src/parser/picker.rs
@@ -743,6 +743,10 @@ where
}
}
+/// Trait for types that can be converted into a `Picker` to extract values from command-line arguments.
+///
+/// This trait provides a convenient way to convert a value (such as `Vec<String>`, `&[String]`, etc.)
+/// into a `Picker` and immediately start extracting values associated with specific flags.
pub trait AsPicker
where
Self: Into<Vec<String>>,
diff --git a/mingling/src/setups.rs b/mingling/src/setups.rs
index a1290ff..6fd728a 100644
--- a/mingling/src/setups.rs
+++ b/mingling/src/setups.rs
@@ -7,6 +7,10 @@ pub use dirs::*;
mod exit_code;
pub use exit_code::*;
+/// Picker's `ProgramSetup` variant.
+///
+/// Internally does not use its own argument parsing,
+/// but relies on `arg_picker`'s argument parsing capability.
#[cfg(feature = "picker")]
pub mod picker;
diff --git a/mingling_core/src/program/setup.rs b/mingling_core/src/program/setup.rs
index f248fb6..838c29a 100644
--- a/mingling_core/src/program/setup.rs
+++ b/mingling_core/src/program/setup.rs
@@ -1,9 +1,26 @@
use crate::{ProgramCollect, program::Program};
+/// Trait for defining initialization/setup logic for a `Program`.
+///
+/// Implementors can define custom setup behavior that will be executed
+/// when the program is initialized via [`Program::with_setup`].
+///
+/// # Type Parameters
+///
+/// * `C` - The program collect type, which must implement [`ProgramCollect`]
+/// and have `Enum = C` (i.e., it collects itself).
pub trait ProgramSetup<C>
where
C: ProgramCollect<Enum = C>,
{
+ /// Perform setup on the given program.
+ ///
+ /// This method consumes the setup instance (`self`) and is called once
+ /// during program initialization.
+ ///
+ /// # Arguments
+ ///
+ /// * `program` - A mutable reference to the [`Program`] being set up.
fn setup(self, program: &mut Program<C>);
}