diff options
Diffstat (limited to 'mingling_macros')
| -rw-r--r-- | mingling_macros/src/attr/command.rs | 6 | ||||
| -rw-r--r-- | mingling_macros/src/attr/dispatcher_clap.rs | 4 | ||||
| -rw-r--r-- | mingling_macros/src/func/program_fallback_gen.rs | 2 | ||||
| -rw-r--r-- | mingling_macros/src/func/program_final_gen.rs | 6 | ||||
| -rw-r--r-- | mingling_macros/src/lib.rs | 12 | ||||
| -rw-r--r-- | mingling_macros/src/systems/dispatch_tree_gen.rs | 12 |
6 files changed, 21 insertions, 21 deletions
diff --git a/mingling_macros/src/attr/command.rs b/mingling_macros/src/attr/command.rs index 35c5c30..9598fa8 100644 --- a/mingling_macros/src/attr/command.rs +++ b/mingling_macros/src/attr/command.rs @@ -179,7 +179,7 @@ fn build_ext_attrs(exts: &[syn::Path]) -> Vec<TokenStream2> { /// Returns `true` if the function has a first non-reference (owned) parameter that /// serves as the "args" input. fn has_args_param(sig: &syn::Signature) -> bool { - sig.inputs.first().map_or(false, |arg| { + sig.inputs.first().is_some_and(|arg| { if let FnArg::Typed(pat_type) = arg { !matches!(&*pat_type.ty, Type::Reference(_)) } else { @@ -202,10 +202,10 @@ fn build_wrapper_params( // First param is owned (args) -> replace its type with entry type let mut params = sig.inputs.clone(); if let Some(FnArg::Typed(first)) = params.first_mut() { - first.ty = Box::new(Type::Path(syn::TypePath { + *first.ty = Type::Path(syn::TypePath { qself: None, path: syn::Path::from(entry_type.clone()), - })); + }); } params } else { diff --git a/mingling_macros/src/attr/dispatcher_clap.rs b/mingling_macros/src/attr/dispatcher_clap.rs index 40f7d47..218750c 100644 --- a/mingling_macros/src/attr/dispatcher_clap.rs +++ b/mingling_macros/src/attr/dispatcher_clap.rs @@ -39,7 +39,7 @@ impl Parse for ClapOptions { error_struct = Some(value); } else if key == "help" { let value: LitBool = input.parse()?; - if value.value() == false { + if !value.value() { // help = false is allowed but does nothing help_enabled = false; } else { @@ -171,7 +171,7 @@ pub(crate) fn dispatcher_clap_attr(attr: TokenStream, item: TokenStream) -> Toke }; let dispatch_tree_entry = - get_dispatch_tree_entry(&command_name_str, dispatcher_struct, &struct_name); + get_dispatch_tree_entry(&command_name_str, dispatcher_struct, struct_name); let expanded = quote! { // Keep the original struct definition diff --git a/mingling_macros/src/func/program_fallback_gen.rs b/mingling_macros/src/func/program_fallback_gen.rs index 3d095e5..93d8616 100644 --- a/mingling_macros/src/func/program_fallback_gen.rs +++ b/mingling_macros/src/func/program_fallback_gen.rs @@ -16,7 +16,7 @@ pub(crate) fn program_fallback_gen_impl(_input: TokenStream) -> TokenStream { let expanded = quote! { ::mingling::macros::pack!(ErrorRendererNotFound = String); - ::mingling::macros::pack!(ErrorDispatcherNotFound = Vec<String>); + ::mingling::macros::pack!(EntryFallback = Vec<String>); #pack_empty }; TokenStream::from(expanded) diff --git a/mingling_macros/src/func/program_final_gen.rs b/mingling_macros/src/func/program_final_gen.rs index 0eed1db..e8545f4 100644 --- a/mingling_macros/src/func/program_final_gen.rs +++ b/mingling_macros/src/func/program_final_gen.rs @@ -298,15 +298,15 @@ pub(crate) fn program_final_gen_impl(_input: TokenStream) -> TokenStream { impl ::mingling::ProgramCollect for #name { type Enum = #name; - type ErrorDispatcherNotFound = ErrorDispatcherNotFound; + type EntryFallback = EntryFallback; type ErrorRendererNotFound = ErrorRendererNotFound; type ResultEmpty = ResultEmpty; fn build_renderer_not_found(member_id: Self::Enum) -> ::mingling::AnyOutput<Self::Enum> { ::mingling::AnyOutput::new(ErrorRendererNotFound::new(member_id.to_string())) } - fn build_dispatcher_not_found(args: Vec<String>) -> ::mingling::AnyOutput<Self::Enum> { - ::mingling::AnyOutput::new(ErrorDispatcherNotFound::new(args)) + fn build_entry_fallback(args: Vec<String>) -> ::mingling::AnyOutput<Self::Enum> { + ::mingling::AnyOutput::new(EntryFallback::new(args)) } fn build_empty_result() -> ::mingling::AnyOutput<Self::Enum> { ::mingling::AnyOutput::new(ResultEmpty) diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs index b6656da..c955e36 100644 --- a/mingling_macros/src/lib.rs +++ b/mingling_macros/src/lib.rs @@ -36,7 +36,7 @@ //! │ V │ //! │ Reads all registries → generates ThisProgram with: │ //! │ • ProgramCollect impl (dispatch/render/chain dispatch tree) │ -//! │ • Fallback types (ErrorDispatcherNotFound, etc.) │ +//! │ • Fallback types (EntryFallback, etc.) │ //! │ • Completion logic (if `comp` feature enabled) │ //! └──────────────────────────────────────────────────────────────────┘ //! ``` @@ -120,8 +120,8 @@ //! ```rust,ignore //! // Example of what gen_program! generates (simplified): //! impl ProgramCollect for ThisProgram { -//! fn build_dispatcher_not_found(args: Vec<String>) -> AnyOutput { -//! AnyOutput::new(ErrorDispatcherNotFound::new(args)) +//! fn build_entry_fallback(args: Vec<String>) -> AnyOutput { +//! AnyOutput::new(EntryFallback::new(args)) //! } //! fn has_chain(any: &AnyOutput) -> bool { //! match any.member_id() { @@ -978,11 +978,11 @@ pub fn chain(attr: TokenStream, item: TokenStream) -> TokenStream { /// The macros `gen_program!` automatically generates two fallback types that /// you can provide renderers for: /// - `ErrorRendererNotFound` — triggered when no matching renderer is found -/// - `ErrorDispatcherNotFound` — triggered when no matching dispatcher is found +/// - `EntryFallback` — triggered when no matching dispatcher is found /// /// ```rust,ignore /// #[renderer] -/// fn fallback_dispatcher_not_found(prev: ErrorDispatcherNotFound) -> RenderResult { +/// fn fallback_dispatcher_not_found(prev: EntryFallback) -> RenderResult { /// let mut result = RenderResult::new(); /// writeln!(result, "Unknown command: {}", prev.join(", ")); /// result @@ -1819,7 +1819,7 @@ pub fn derive_grouped_serialize(input: TokenStream) -> TokenStream { /// 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 `ErrorRendererNotFound` and `ErrorDispatcherNotFound` types. +/// 3. **`program_fallback_gen!(...)`** — Generates `ErrorRendererNotFound` and `EntryFallback` types. /// 4. **`program_final_gen!(...)`** — Generates the program enum with: /// - An enum with all packed types as variants /// - `Display` implementation for the enum diff --git a/mingling_macros/src/systems/dispatch_tree_gen.rs b/mingling_macros/src/systems/dispatch_tree_gen.rs index fe44a49..8e3660c 100644 --- a/mingling_macros/src/systems/dispatch_tree_gen.rs +++ b/mingling_macros/src/systems/dispatch_tree_gen.rs @@ -61,7 +61,7 @@ pub(crate) fn gen_dispatch_args_trie(entries: &[(String, String, String)]) -> To fn build_dispatch_body(nodes: &[(String, String)], depth: usize) -> TokenStream { if nodes.is_empty() { return quote! { - return Ok(Self::build_dispatcher_not_found(raw.to_vec())); + return Ok(Self::build_entry_fallback(raw.to_vec())); }; } @@ -113,7 +113,7 @@ fn build_dispatch_body(nodes: &[(String, String)], depth: usize) -> TokenStream arms.push(quote! { Some(#ch_char) => { #arm - return Ok(Self::build_dispatcher_not_found(raw.to_vec())); + return Ok(Self::build_entry_fallback(raw.to_vec())); } }); } else { @@ -135,7 +135,7 @@ fn build_dispatch_body(nodes: &[(String, String)], depth: usize) -> TokenStream let match_body = quote! { match raw_chars.nth(0) { #(#arms)* - _ => return Ok(Self::build_dispatcher_not_found(raw.to_vec())), + _ => return Ok(Self::build_entry_fallback(raw.to_vec())), } }; quote! { @@ -145,17 +145,17 @@ fn build_dispatch_body(nodes: &[(String, String)], depth: usize) -> TokenStream } else if !exact_checks.is_empty() { quote! { #(#exact_checks)* - return Ok(Self::build_dispatcher_not_found(raw.to_vec())); + return Ok(Self::build_entry_fallback(raw.to_vec())); } } else if arms.is_empty() { quote! { - return Ok(Self::build_dispatcher_not_found(raw.to_vec())); + return Ok(Self::build_entry_fallback(raw.to_vec())); } } else { quote! { match raw_chars.nth(0) { #(#arms)* - _ => return Ok(Self::build_dispatcher_not_found(raw.to_vec())), + _ => return Ok(Self::build_entry_fallback(raw.to_vec())), } } } |
