chore: use std::sync::LazyLock

This commit is contained in:
Vukašin Vojinović 2025-07-21 14:39:10 +02:00 committed by Victoria Brekenfeld
parent 310cf212eb
commit fec7c94605
4 changed files with 46 additions and 55 deletions

View file

@ -4,10 +4,8 @@
macro_rules! id_gen {
($func_name:ident, $id_name:ident, $ids_name:ident) => {
static $id_name: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
lazy_static::lazy_static! {
static ref $ids_name: std::sync::Mutex<std::collections::HashSet<usize>> =
std::sync::Mutex::new(std::collections::HashSet::new());
}
static $ids_name: std::sync::LazyLock<std::sync::Mutex<std::collections::HashSet<usize>>> =
std::sync::LazyLock::new(|| std::sync::Mutex::new(std::collections::HashSet::new()));
fn $func_name() -> usize {
let mut ids = $ids_name.lock().unwrap();