From 0a2ef958c0dca21d19e4ffc38ba5a7c4078e182a Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Sat, 23 May 2026 23:41:04 +0800 Subject: Rework examples and add entry macro for testing --- mingling_macros/src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'mingling_macros/src/lib.rs') diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs index 8c98ba3..57f37a1 100644 --- a/mingling_macros/src/lib.rs +++ b/mingling_macros/src/lib.rs @@ -33,6 +33,7 @@ mod dispatch_tree_gen; mod dispatcher; #[cfg(feature = "clap")] mod dispatcher_clap; +mod entry; mod enum_tag; mod groupped; mod help; @@ -776,6 +777,27 @@ pub fn dispatcher_clap(attr: TokenStream, item: TokenStream) -> TokenStream { dispatcher_clap::dispatcher_clap_attr(attr, item) } +/// Creates a packed entry value from a list of string literals. +/// +/// # Syntax +/// +/// Two forms: +/// +/// ```rust,ignore +/// // With explicit type — expands to MyEntry::new(vec!["a".to_string(), ...]) +/// entry!(MyEntry, ["a", "b", "c"]) +/// +/// // Without type — use bracket syntax, expands to vec!["a".to_string(), ...].into() +/// entry!["a", "b", "c"] +/// ``` +/// +/// This is a convenience macro for constructing entry wrapper types (created +/// via `pack!` or `dispatcher!`) with test data. +#[proc_macro] +pub fn entry(input: TokenStream) -> TokenStream { + entry::entry(input) +} + /// Registers a help request mapping between an entry type and a help struct. /// /// This macro is used internally by the `#[help]`(macro.help.html) attribute -- cgit