1 2 3 4 5 6 7 8 9
use std::sync::{Mutex, MutexGuard, OnceLock}; pub(super) fn lock_env() -> MutexGuard<'static, ()> { static ENV_LOCK: OnceLock<Mutex<()>> = OnceLock::new(); ENV_LOCK .get_or_init(|| Mutex::new(())) .lock() .unwrap_or_else(|e| e.into_inner()) }