aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros/src/lib.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-05-02 01:38:36 +0800
committer魏曹先生 <1992414357@qq.com>2026-05-02 01:40:11 +0800
commit81be96847833bd443ddb157cedb7939d8ffcc150 (patch)
treeb8f476d4430ed435f3ac93a1553219a349c0baca /mingling_macros/src/lib.rs
parent1da9fc6103c06015942cf6c06f5fe015479c2706 (diff)
Enforce `NextProcess` return type in chain functions and update examples
Diffstat (limited to 'mingling_macros/src/lib.rs')
-rw-r--r--mingling_macros/src/lib.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs
index 70a5c3e..818cda6 100644
--- a/mingling_macros/src/lib.rs
+++ b/mingling_macros/src/lib.rs
@@ -316,14 +316,14 @@ pub fn r_println(input: TokenStream) -> TokenStream {
/// ```rust,ignore
/// // Default program (ThisProgram):
/// #[chain]
-/// fn my_step(prev: InputType) -> ChainProcess<ThisProgram> {
+/// fn my_step(prev: InputType) -> NextProcess {
/// // transform `prev`...
/// OutputType::new(result).to_render()
/// }
///
/// // Explicit program name:
/// #[chain(MyProgram)]
-/// fn my_step(prev: InputType) -> ChainProcess<MyProgram> {
+/// fn my_step(prev: InputType) -> NextProcess {
/// // ...
/// }
/// ```
@@ -336,7 +336,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
/// pack!(MyOutput = String);
///
/// #[chain]
-/// fn greet(prev: HelloEntry) -> ChainProcess<ThisProgram> {
+/// fn greet(prev: HelloEntry) -> NextProcess {
/// let name = prev.first().cloned().unwrap_or_else(|| "World".to_string());
/// MyOutput::new(name).to_render()
/// }
@@ -350,7 +350,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
/// pack!(MyOutput = String);
///
/// #[chain]
-/// async fn greet(prev: HelloEntry) -> ChainProcess<ThisProgram> {
+/// async fn greet(prev: HelloEntry) -> NextProcess {
/// let name = prev.first().cloned().unwrap_or_else(|| "World".to_string());
/// some_async_fn(&name).await;
/// MyOutput::new(name).to_render()
@@ -360,7 +360,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
/// # Requirements
///
/// - The function must have exactly **one** parameter (the previous type in the chain).
-/// - The function must return `ChainProcess<ProgramName>` (or `impl Into<ChainProcess<ProgramName>>`).
+/// - The function must return `NextProcess` (the type alias generated by `gen_program!`, which equals `ChainProcess<ProgramName>`).
/// - With the `async` feature, async functions are supported; without it, async functions are rejected.
#[proc_macro_attribute]
pub fn chain(attr: TokenStream, item: TokenStream) -> TokenStream {
@@ -857,7 +857,7 @@ pub fn program_comp_gen(input: TokenStream) -> TokenStream {
#[cfg(feature = "async")]
let fn_exec_comp = quote! {
#[::mingling::macros::chain(#name)]
- pub async fn __exec_completion(prev: CompletionContext) -> ::mingling::ChainProcess<#name> {
+ pub async fn __exec_completion(prev: CompletionContext) -> NextProcess {
let read_ctx = ::mingling::ShellContext::try_from(prev.inner);
match read_ctx {
Ok(ctx) => {
@@ -872,7 +872,7 @@ pub fn program_comp_gen(input: TokenStream) -> TokenStream {
#[cfg(not(feature = "async"))]
let fn_exec_comp = quote! {
#[::mingling::macros::chain(#name)]
- pub fn __exec_completion(prev: CompletionContext) -> ::mingling::ChainProcess<#name> {
+ pub fn __exec_completion(prev: CompletionContext) -> NextProcess {
let read_ctx = ::mingling::ShellContext::try_from(prev.inner);
match read_ctx {
Ok(ctx) => {