aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-05-21 15:02:50 +0800
committer魏曹先生 <1992414357@qq.com>2026-05-21 15:03:55 +0800
commit4704f6d54108bcc8f9b2fb7f4b3c4e224b4a7809 (patch)
tree425b15395de24717f9732d8642e75044774d4583
parenta9755711b490529c26bdb4b024c6caf825940dd3 (diff)
Remove `once_cell` dependency and replace with `OnceLock`
-rw-r--r--CHANGELOG.md3
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml1
-rw-r--r--examples/example-async/Cargo.lock8
-rw-r--r--examples/example-basic/Cargo.lock8
-rw-r--r--examples/example-completion/Cargo.lock8
-rw-r--r--examples/example-dispatch-tree/Cargo.lock8
-rw-r--r--examples/example-exit-code/Cargo.lock8
-rw-r--r--examples/example-general-renderer/Cargo.lock8
-rw-r--r--examples/example-picker/Cargo.lock8
-rw-r--r--examples/example-repl/Cargo.lock8
-rw-r--r--examples/example-resources/Cargo.lock8
-rw-r--r--mingling_core/Cargo.toml1
-rw-r--r--mingling_macros/Cargo.toml1
-rw-r--r--mingling_macros/src/chain.rs4
-rw-r--r--mingling_macros/src/completion.rs4
-rw-r--r--mingling_macros/src/dispatcher.rs11
-rw-r--r--mingling_macros/src/help.rs12
-rw-r--r--mingling_macros/src/lib.rs58
-rw-r--r--mingling_macros/src/renderer.rs8
20 files changed, 58 insertions, 119 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e10c307..8ea9625 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,8 +6,9 @@
None
### Optimizings:
-None
+1. **\[macros\]** Removed dependency `once_cell`, replaced with `std::sync::OnceLock`
+#### Features:
1. **\[macros\]** Added the `empty_result!()` macro for early return from a chain function. This macro is a shorthand for constructing an `EmptyResult` and converting it into a `ChainProcess`, signaling to the pipeline that there is no meaningful output to continue processing.
```rust
diff --git a/Cargo.lock b/Cargo.lock
index 9f60cfe..c8beae0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -304,7 +304,6 @@ dependencies = [
"just_fmt",
"just_template",
"log",
- "once_cell",
"ron",
"serde",
"serde_json",
@@ -317,7 +316,6 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
diff --git a/Cargo.toml b/Cargo.toml
index 4777818..9e2240b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,6 @@ exclude = [
[workspace.dependencies]
just_fmt = "0.1.2"
just_template = "0.1.3"
-once_cell = "1.21.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
diff --git a/examples/example-async/Cargo.lock b/examples/example-async/Cargo.lock
index d8c1122..b7dd453 100644
--- a/examples/example-async/Cargo.lock
+++ b/examples/example-async/Cargo.lock
@@ -72,7 +72,6 @@ name = "mingling_core"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
]
[[package]]
@@ -80,7 +79,6 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
@@ -98,12 +96,6 @@ dependencies = [
]
[[package]]
-name = "once_cell"
-version = "1.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
-
-[[package]]
name = "parking_lot"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/examples/example-basic/Cargo.lock b/examples/example-basic/Cargo.lock
index 9b86098..de110d2 100644
--- a/examples/example-basic/Cargo.lock
+++ b/examples/example-basic/Cargo.lock
@@ -28,7 +28,6 @@ name = "mingling_core"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
]
[[package]]
@@ -36,19 +35,12 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
]
[[package]]
-name = "once_cell"
-version = "1.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
-
-[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/examples/example-completion/Cargo.lock b/examples/example-completion/Cargo.lock
index d61cc11..d027a14 100644
--- a/examples/example-completion/Cargo.lock
+++ b/examples/example-completion/Cargo.lock
@@ -39,7 +39,6 @@ version = "0.1.9"
dependencies = [
"just_fmt",
"just_template",
- "once_cell",
]
[[package]]
@@ -47,19 +46,12 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
]
[[package]]
-name = "once_cell"
-version = "1.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
-
-[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/examples/example-dispatch-tree/Cargo.lock b/examples/example-dispatch-tree/Cargo.lock
index c9610b9..4085ce5 100644
--- a/examples/example-dispatch-tree/Cargo.lock
+++ b/examples/example-dispatch-tree/Cargo.lock
@@ -38,7 +38,6 @@ version = "0.1.9"
dependencies = [
"just_fmt",
"just_template",
- "once_cell",
]
[[package]]
@@ -46,19 +45,12 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
]
[[package]]
-name = "once_cell"
-version = "1.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
-
-[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/examples/example-exit-code/Cargo.lock b/examples/example-exit-code/Cargo.lock
index 60e089a..2ba3ffe 100644
--- a/examples/example-exit-code/Cargo.lock
+++ b/examples/example-exit-code/Cargo.lock
@@ -28,7 +28,6 @@ name = "mingling_core"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
]
[[package]]
@@ -36,19 +35,12 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
]
[[package]]
-name = "once_cell"
-version = "1.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
-
-[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/examples/example-general-renderer/Cargo.lock b/examples/example-general-renderer/Cargo.lock
index 2eeee0d..f0f0eea 100644
--- a/examples/example-general-renderer/Cargo.lock
+++ b/examples/example-general-renderer/Cargo.lock
@@ -65,7 +65,6 @@ name = "mingling_core"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"serde",
"serde_json",
"serde_yaml",
@@ -76,19 +75,12 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
]
[[package]]
-name = "once_cell"
-version = "1.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
-
-[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/examples/example-picker/Cargo.lock b/examples/example-picker/Cargo.lock
index 8532728..eada902 100644
--- a/examples/example-picker/Cargo.lock
+++ b/examples/example-picker/Cargo.lock
@@ -30,7 +30,6 @@ name = "mingling_core"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
]
[[package]]
@@ -38,19 +37,12 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
]
[[package]]
-name = "once_cell"
-version = "1.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
-
-[[package]]
name = "pin-project-lite"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/examples/example-repl/Cargo.lock b/examples/example-repl/Cargo.lock
index cabbe98..adde389 100644
--- a/examples/example-repl/Cargo.lock
+++ b/examples/example-repl/Cargo.lock
@@ -30,7 +30,6 @@ name = "mingling_core"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
]
[[package]]
@@ -38,19 +37,12 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
]
[[package]]
-name = "once_cell"
-version = "1.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
-
-[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/examples/example-resources/Cargo.lock b/examples/example-resources/Cargo.lock
index 27bc9b6..63467d0 100644
--- a/examples/example-resources/Cargo.lock
+++ b/examples/example-resources/Cargo.lock
@@ -29,7 +29,6 @@ name = "mingling_core"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
]
[[package]]
@@ -37,19 +36,12 @@ name = "mingling_macros"
version = "0.1.9"
dependencies = [
"just_fmt",
- "once_cell",
"proc-macro2",
"quote",
"syn",
]
[[package]]
-name = "once_cell"
-version = "1.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
-
-[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/mingling_core/Cargo.toml b/mingling_core/Cargo.toml
index dcc3fef..26e642b 100644
--- a/mingling_core/Cargo.toml
+++ b/mingling_core/Cargo.toml
@@ -27,7 +27,6 @@ debug = ["dep:log", "dep:env_logger"]
[dependencies]
just_fmt.workspace = true
-once_cell.workspace = true
# comp
just_template = { workspace = true, optional = true }
diff --git a/mingling_macros/Cargo.toml b/mingling_macros/Cargo.toml
index 1464d54..4f2b094 100644
--- a/mingling_macros/Cargo.toml
+++ b/mingling_macros/Cargo.toml
@@ -26,4 +26,3 @@ quote.workspace = true
proc-macro2.workspace = true
just_fmt.workspace = true
-once_cell.workspace = true
diff --git a/mingling_macros/src/chain.rs b/mingling_macros/src/chain.rs
index 5ec5635..6e5fd64 100644
--- a/mingling_macros/src/chain.rs
+++ b/mingling_macros/src/chain.rs
@@ -628,8 +628,8 @@ pub fn register_chain(input: TokenStream) -> TokenStream {
// Record the chain existence check
let chain_exist_entry = build_chain_exist_arm(&previous_type);
- let mut chains = crate::CHAINS.lock().unwrap();
- let mut chain_exist = crate::CHAINS_EXIST.lock().unwrap();
+ let mut chains = crate::get_global_set(&crate::CHAINS).lock().unwrap();
+ let mut chain_exist = crate::get_global_set(&crate::CHAINS_EXIST).lock().unwrap();
let chain_entry_str = chain_entry.to_string();
let chain_exist_entry_str = chain_exist_entry.to_string();
diff --git a/mingling_macros/src/completion.rs b/mingling_macros/src/completion.rs
index cd4a9ad..ba0de2e 100644
--- a/mingling_macros/src/completion.rs
+++ b/mingling_macros/src/completion.rs
@@ -6,6 +6,8 @@ use syn::{FnArg, Ident, ItemFn, PatType, Type, parse_macro_input};
#[cfg(feature = "comp")]
pub fn completion_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
// Parse the attribute arguments (e.g., HelloEntry from #[completion(HelloEntry)])
+
+ use crate::get_global_set;
let previous_type_ident = if attr.is_empty() {
return syn::Error::new(
proc_macro2::Span::call_site(),
@@ -109,7 +111,7 @@ pub fn completion_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
Self::#previous_type_ident => <#struct_name as ::mingling::Completion>::comp(ctx),
};
- let mut completions = crate::COMPLETIONS.lock().unwrap();
+ let mut completions = get_global_set(&crate::COMPLETIONS).lock().unwrap();
let completion_str = completion_entry.to_string();
completions.insert(completion_str);
diff --git a/mingling_macros/src/dispatcher.rs b/mingling_macros/src/dispatcher.rs
index 9724fd1..e327d6b 100644
--- a/mingling_macros/src/dispatcher.rs
+++ b/mingling_macros/src/dispatcher.rs
@@ -208,10 +208,13 @@ pub fn register_dispatcher(input: TokenStream) -> TokenStream {
// Register node info in the global collection at compile time
// Format: "node.name:DispatcherType:EntryName"
- COMPILE_TIME_DISPATCHERS.lock().unwrap().insert(format!(
- "{}:{}:{}",
- node_name_str, dispatcher_type, entry_name
- ));
+ crate::get_global_set(&COMPILE_TIME_DISPATCHERS)
+ .lock()
+ .unwrap()
+ .insert(format!(
+ "{}:{}:{}",
+ node_name_str, dispatcher_type, entry_name
+ ));
let expanded = quote! {
#[doc(hidden)]
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()
}
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs
index badb117..29c46b4 100644
--- a/mingling_macros/src/lib.rs
+++ b/mingling_macros/src/lib.rs
@@ -17,12 +17,12 @@
//! - **Internal registration**: `register_type!`, `register_chain!`, `register_renderer!`,
//! `program_fallback_gen!`, `program_final_gen!`, `program_comp_gen!`
-use once_cell::sync::Lazy;
use proc_macro::TokenStream;
use proc_macro2::Ident;
use quote::quote;
use std::collections::BTreeSet;
use std::sync::Mutex;
+use std::sync::OnceLock;
use syn::parse_macro_input;
mod chain;
@@ -55,29 +55,26 @@ pub(crate) fn default_program_path() -> proc_macro2::TokenStream {
quote::quote! { crate::ThisProgram }
}
+// Helper to get or init a OnceLock<Mutex<BTreeSet<String>>>
+pub(crate) fn get_global_set(lock: &OnceLock<Mutex<BTreeSet<String>>>) -> &Mutex<BTreeSet<String>> {
+ lock.get_or_init(|| Mutex::new(BTreeSet::new()))
+}
+
// Global variables
#[cfg(feature = "general_renderer")]
-pub(crate) static GENERAL_RENDERERS: Lazy<Mutex<BTreeSet<String>>> =
- Lazy::new(|| Mutex::new(BTreeSet::new()));
+pub(crate) static GENERAL_RENDERERS: OnceLock<Mutex<BTreeSet<String>>> = OnceLock::new();
#[cfg(feature = "comp")]
-pub(crate) static COMPLETIONS: Lazy<Mutex<BTreeSet<String>>> =
- Lazy::new(|| Mutex::new(BTreeSet::new()));
+pub(crate) static COMPLETIONS: OnceLock<Mutex<BTreeSet<String>>> = OnceLock::new();
#[cfg(feature = "dispatch_tree")]
-pub(crate) static COMPILE_TIME_DISPATCHERS: Lazy<Mutex<BTreeSet<String>>> =
- Lazy::new(|| Mutex::new(BTreeSet::new()));
-
-pub(crate) static PACKED_TYPES: Lazy<Mutex<BTreeSet<String>>> =
- Lazy::new(|| Mutex::new(BTreeSet::new()));
-pub(crate) static CHAINS: Lazy<Mutex<BTreeSet<String>>> = Lazy::new(|| Mutex::new(BTreeSet::new()));
-pub(crate) static RENDERERS: Lazy<Mutex<BTreeSet<String>>> =
- Lazy::new(|| Mutex::new(BTreeSet::new()));
-pub(crate) static CHAINS_EXIST: Lazy<Mutex<BTreeSet<String>>> =
- Lazy::new(|| Mutex::new(BTreeSet::new()));
-pub(crate) static RENDERERS_EXIST: Lazy<Mutex<BTreeSet<String>>> =
- Lazy::new(|| Mutex::new(BTreeSet::new()));
-pub(crate) static HELP_REQUESTS: Lazy<Mutex<BTreeSet<String>>> =
- Lazy::new(|| Mutex::new(BTreeSet::new()));
+pub(crate) static COMPILE_TIME_DISPATCHERS: OnceLock<Mutex<BTreeSet<String>>> = OnceLock::new();
+
+pub(crate) static PACKED_TYPES: OnceLock<Mutex<BTreeSet<String>>> = OnceLock::new();
+pub(crate) static CHAINS: OnceLock<Mutex<BTreeSet<String>>> = OnceLock::new();
+pub(crate) static RENDERERS: OnceLock<Mutex<BTreeSet<String>>> = OnceLock::new();
+pub(crate) static CHAINS_EXIST: OnceLock<Mutex<BTreeSet<String>>> = OnceLock::new();
+pub(crate) static RENDERERS_EXIST: OnceLock<Mutex<BTreeSet<String>>> = OnceLock::new();
+pub(crate) static HELP_REQUESTS: OnceLock<Mutex<BTreeSet<String>>> = OnceLock::new();
/// Checks that a TypePath is a simple single-segment identifier (no `::` in the path).
///
@@ -1137,7 +1134,10 @@ pub fn register_type(input: TokenStream) -> TokenStream {
let type_ident = parse_macro_input!(input as syn::Ident);
let entry_str = type_ident.to_string();
- PACKED_TYPES.lock().unwrap().insert(entry_str);
+ get_global_set(&PACKED_TYPES)
+ .lock()
+ .unwrap()
+ .insert(entry_str);
TokenStream::new()
}
@@ -1280,18 +1280,18 @@ pub fn program_fallback_gen(input: TokenStream) -> TokenStream {
pub fn program_final_gen(input: TokenStream) -> TokenStream {
let name = read_name(&input);
- let packed_types = PACKED_TYPES.lock().unwrap().clone();
+ let packed_types = get_global_set(&PACKED_TYPES).lock().unwrap().clone();
- let renderers = RENDERERS.lock().unwrap().clone();
- let chains = CHAINS.lock().unwrap().clone();
- let renderer_exist = RENDERERS_EXIST.lock().unwrap().clone();
- let chain_exist = CHAINS_EXIST.lock().unwrap().clone();
+ let renderers = get_global_set(&RENDERERS).lock().unwrap().clone();
+ let chains = get_global_set(&CHAINS).lock().unwrap().clone();
+ let renderer_exist = get_global_set(&RENDERERS_EXIST).lock().unwrap().clone();
+ let chain_exist = get_global_set(&CHAINS_EXIST).lock().unwrap().clone();
#[cfg(feature = "general_renderer")]
- let general_renderers = GENERAL_RENDERERS.lock().unwrap().clone();
+ let general_renderers = get_global_set(&GENERAL_RENDERERS).lock().unwrap().clone();
#[cfg(feature = "comp")]
- let completions = COMPLETIONS.lock().unwrap().clone();
+ let completions = get_global_set(&COMPLETIONS).lock().unwrap().clone();
let packed_types: Vec<proc_macro2::TokenStream> = packed_types
.iter()
@@ -1341,7 +1341,7 @@ pub fn program_final_gen(input: TokenStream) -> TokenStream {
let general_render = quote! {};
#[cfg(feature = "dispatch_tree")]
- let compile_time_dispatchers: Vec<String> = COMPILE_TIME_DISPATCHERS
+ let compile_time_dispatchers: Vec<String> = get_global_set(&COMPILE_TIME_DISPATCHERS)
.lock()
.unwrap()
.clone()
@@ -1398,7 +1398,7 @@ pub fn program_final_gen(input: TokenStream) -> TokenStream {
#[cfg(not(feature = "comp"))]
let comp = quote! {};
- let help_tokens: Vec<proc_macro2::TokenStream> = HELP_REQUESTS
+ let help_tokens: Vec<proc_macro2::TokenStream> = get_global_set(&HELP_REQUESTS)
.lock()
.unwrap()
.clone()
diff --git a/mingling_macros/src/renderer.rs b/mingling_macros/src/renderer.rs
index 36ebf54..d2c2221 100644
--- a/mingling_macros/src/renderer.rs
+++ b/mingling_macros/src/renderer.rs
@@ -3,6 +3,8 @@ use quote::{ToTokens, quote};
use syn::spanned::Spanned;
use syn::{FnArg, 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
@@ -212,11 +214,11 @@ pub fn register_renderer(input: TokenStream) -> TokenStream {
#[cfg(feature = "general_renderer")]
let general_renderer_entry = build_general_renderer_entry(&previous_type);
- let mut renderers = crate::RENDERERS.lock().unwrap();
- let mut renderer_exist = crate::RENDERERS_EXIST.lock().unwrap();
+ let mut renderers = get_global_set(&crate::RENDERERS).lock().unwrap();
+ let mut renderer_exist = get_global_set(&crate::RENDERERS_EXIST).lock().unwrap();
#[cfg(feature = "general_renderer")]
- let mut general_renderers = crate::GENERAL_RENDERERS.lock().unwrap();
+ let mut general_renderers = get_global_set(&crate::GENERAL_RENDERERS).lock().unwrap();
let renderer_entry_str = renderer_entry.to_string();
let renderer_exist_entry_str = renderer_exist_entry.to_string();