diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-23 23:41:04 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-23 23:49:34 +0800 |
| commit | 0a2ef958c0dca21d19e4ffc38ba5a7c4078e182a (patch) | |
| tree | c82fc4242ed393b132ba514eb434d722e7d9c387 /mingling_macros/src/lib.rs | |
| parent | ccab1940c019dfbfb7dfcbbe4cb927258933755f (diff) | |
Rework examples and add entry macro for testing
Diffstat (limited to 'mingling_macros/src/lib.rs')
| -rw-r--r-- | mingling_macros/src/lib.rs | 22 |
1 files changed, 22 insertions, 0 deletions
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 |
