diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-05-21 15:02:50 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-21 15:03:55 +0800 |
| commit | 4704f6d54108bcc8f9b2fb7f4b3c4e224b4a7809 (patch) | |
| tree | 425b15395de24717f9732d8642e75044774d4583 /mingling_macros/src/help.rs | |
| parent | a9755711b490529c26bdb4b024c6caf825940dd3 (diff) | |
Remove `once_cell` dependency and replace with `OnceLock`
Diffstat (limited to 'mingling_macros/src/help.rs')
| -rw-r--r-- | mingling_macros/src/help.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mingling_macros/src/help.rs b/mingling_macros/src/help.rs index 6667ae0..7ce9e83 100644 --- a/mingling_macros/src/help.rs +++ b/mingling_macros/src/help.rs @@ -5,6 +5,8 @@ use syn::{ FnArg, Ident, ItemFn, Pat, PatType, ReturnType, Signature, Type, TypePath, parse_macro_input, }; +use crate::get_global_set; + /// Extracts the previous type and parameter name from function arguments fn extract_previous_info(sig: &Signature) -> syn::Result<(Pat, TypePath)> { // The function should have exactly one parameter @@ -102,7 +104,10 @@ pub fn help_attr(item: TokenStream) -> TokenStream { // Register the help request mapping let help_entry = build_help_entry(&struct_name, &entry_type); let entry_str = help_entry.to_string(); - crate::HELP_REQUESTS.lock().unwrap().insert(entry_str); + get_global_set(&crate::HELP_REQUESTS) + .lock() + .unwrap() + .insert(entry_str); // Generate the struct and HelpRequest implementation let expanded = quote! { @@ -186,7 +191,10 @@ pub fn register_help(input: TokenStream) -> TokenStream { // Register the help request mapping let help_entry = build_help_entry(&struct_name, &entry_type); let entry_str = help_entry.to_string(); - crate::HELP_REQUESTS.lock().unwrap().insert(entry_str); + get_global_set(&crate::HELP_REQUESTS) + .lock() + .unwrap() + .insert(entry_str); quote! {}.into() } |
