aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-05-17 22:30:50 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-05-17 22:38:39 +0800
commitf27f5aeb09616b932ab48f0905994879dd8bafe5 (patch)
tree2deea67f7ed910ad824fbcce2330ab5c475e51a0 /mingling_macros
parentbdd736ad9899aed74aaa2760c6e068dcae0e6925 (diff)
Rename `NextProcess` to `Next` across the codebase
Diffstat (limited to 'mingling_macros')
-rw-r--r--mingling_macros/src/chain.rs17
-rw-r--r--mingling_macros/src/lib.rs30
2 files changed, 23 insertions, 24 deletions
diff --git a/mingling_macros/src/chain.rs b/mingling_macros/src/chain.rs
index 111c584..02bbc6f 100644
--- a/mingling_macros/src/chain.rs
+++ b/mingling_macros/src/chain.rs
@@ -153,23 +153,22 @@ fn parse_chain_attr_args(attr: TokenStream) -> (proc_macro2::TokenStream, bool)
}
}
-/// Validates that the return type of the function is `NextProcess`.
+/// Validates that the return type of the function is `Next`.
fn validate_return_type_is_next_process(sig: &Signature) -> Result<(), proc_macro2::TokenStream> {
match &sig.output {
ReturnType::Type(_, ty) => match &**ty {
Type::Path(type_path) => {
let last_segment = type_path.path.segments.last().unwrap();
- if last_segment.ident != "NextProcess" {
- return Err(syn::Error::new(
- ty.span(),
- "Chain function must return `NextProcess`",
- )
- .to_compile_error());
+ if last_segment.ident != "Next" {
+ return Err(
+ syn::Error::new(ty.span(), "Chain function must return `Next`")
+ .to_compile_error(),
+ );
}
}
_ => {
return Err(
- syn::Error::new(ty.span(), "Chain function must return `NextProcess`")
+ syn::Error::new(ty.span(), "Chain function must return `Next`")
.to_compile_error(),
);
}
@@ -177,7 +176,7 @@ fn validate_return_type_is_next_process(sig: &Signature) -> Result<(), proc_macr
ReturnType::Default => {
return Err(syn::Error::new(
sig.span(),
- "Chain function must specify a return type (must be `NextProcess`)",
+ "Chain function must specify a return type (must be `Next`)",
)
.to_compile_error());
}
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs
index d5bdf35..85b89a3 100644
--- a/mingling_macros/src/lib.rs
+++ b/mingling_macros/src/lib.rs
@@ -362,14 +362,14 @@ pub fn r_println(input: TokenStream) -> TokenStream {
/// ```rust,ignore
/// // Default program (ThisProgram):
/// #[chain]
-/// fn my_step(prev: InputType) -> NextProcess {
+/// fn my_step(prev: InputType) -> Next {
/// // transform `prev`...
/// OutputType::new(result)
/// }
///
/// // Explicit program name:
/// #[chain(MyProgram)]
-/// fn my_step(prev: InputType) -> NextProcess {
+/// fn my_step(prev: InputType) -> Next {
/// // ...
/// }
/// ```
@@ -387,7 +387,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
///
/// ```rust,ignore
/// #[chain]
-/// fn process(prev: HelloEntry, age: &Age, name: &Name) -> NextProcess {
+/// fn process(prev: HelloEntry, age: &Age, name: &Name) -> Next {
/// // `age` and `name` are automatically injected
/// println!("Age: {}, Name: {}", age, name);
/// NextStep::default()
@@ -410,7 +410,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
///
/// ```rust,ignore
/// #[chain]
-/// fn process(prev: HelloEntry, count: &mut InvocationCount, name: &Name) -> NextProcess {
+/// fn process(prev: HelloEntry, count: &mut InvocationCount, name: &Name) -> Next {
/// count.0 += 1;
/// println!("Invocation #{} for {}", count.0, name);
/// NextStep::default()
@@ -448,7 +448,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
/// pack!(MyOutput = String);
///
/// #[chain]
-/// fn greet(prev: HelloEntry) -> NextProcess {
+/// fn greet(prev: HelloEntry) -> Next {
/// let name = prev.first().cloned().unwrap_or_else(|| "World".to_string());
/// MyOutput::new(name)
/// }
@@ -466,7 +466,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
/// pack!(DisplayCount = ());
///
/// #[chain]
-/// fn greet(prev: HelloEntry, user_name: &UserName, count: &mut u64) -> NextProcess {
+/// fn greet(prev: HelloEntry, user_name: &UserName, count: &mut u64) -> Next {
/// r_println!("User: {:?}", user_name);
/// *count += 1;
/// Greeting::new(format!("Hello, {}!", user_name.0))
@@ -481,7 +481,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
/// pack!(MyOutput = String);
///
/// #[chain]
-/// async fn greet(prev: HelloEntry) -> NextProcess {
+/// async fn greet(prev: HelloEntry) -> Next {
/// let name = prev.first().cloned().unwrap_or_else(|| "World".to_string());
/// some_async_fn(&name).await;
/// MyOutput::new(name)
@@ -496,7 +496,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
/// pack!(MyOutput = String);
///
/// #[chain]
-/// async fn greet(prev: HelloEntry, prefix: &Prefix) -> NextProcess {
+/// async fn greet(prev: HelloEntry, prefix: &Prefix) -> Next {
/// let name = prev.first().cloned().unwrap_or_else(|| "World".to_string());
/// some_async_fn(&name).await;
/// MyOutput::new(format!("{}{}", prefix.0, name))
@@ -507,7 +507,7 @@ pub fn r_println(input: TokenStream) -> TokenStream {
///
/// - The function must have at least **one** parameter (the previous type in the chain).
/// - The first parameter must be taken **by move**.
-/// - The function must return `NextProcess` (the type alias generated by `gen_program!`, which equals `ChainProcess<ProgramName>`).
+/// - The function must return `Next` (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 {
@@ -948,7 +948,7 @@ pub fn derive_groupped_serialize(input: TokenStream) -> TokenStream {
/// # What it generates
///
/// The macro expands to:
-/// 1. **`pub type NextProcess = ChainProcess<ProgramName>`** — A convenience type alias
+/// 1. **`pub type Next = ChainProcess<ProgramName>`** — A convenience type alias
/// for use in chain function return types.
/// 2. **`program_comp_gen!(...)`** (with `comp` feature) — Generates completion infrastructure.
/// 3. **`program_fallback_gen!(...)`** — Generates `RendererNotFound` and `DispatcherNotFound` types.
@@ -966,7 +966,7 @@ pub fn derive_groupped_serialize(input: TokenStream) -> TokenStream {
/// dispatcher!("hello", HelloCommand => HelloEntry);
///
/// #[chain]
-/// fn process(prev: HelloEntry) -> NextProcess {
+/// fn process(prev: HelloEntry) -> Next {
/// // ...
/// }
///
@@ -993,8 +993,8 @@ pub fn gen_program(input: TokenStream) -> TokenStream {
TokenStream::from(quote! {
// Shit, this feature is unstable
// TODO :: This logic will be implemented when Rust's Impl In Type Alias feature becomes stable
- // pub type NextProcess = impl Into<::mingling::ChainProcess<#name>>;
- pub type NextProcess = ::mingling::ChainProcess<#name>;
+ // pub type Next = impl Into<::mingling::ChainProcess<#name>>;
+ pub type Next = ::mingling::ChainProcess<#name>;
#comp_gen
::mingling::macros::program_fallback_gen!(#name);
@@ -1022,7 +1022,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) -> NextProcess {
+ pub async fn __exec_completion(prev: CompletionContext) -> Next {
let read_ctx = ::mingling::ShellContext::try_from(prev.inner);
match read_ctx {
Ok(ctx) => {
@@ -1037,7 +1037,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) -> NextProcess {
+ pub fn __exec_completion(prev: CompletionContext) -> Next {
let read_ctx = ::mingling::ShellContext::try_from(prev.inner);
match read_ctx {
Ok(ctx) => {