diff options
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index cc4154c..4aac0cf 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,11 +1,10 @@ -use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard}; +use std::ptr::addr_of_mut; -use lazy_static::lazy_static; use mlua::{UserData, UserDataFields}; use self::{keymap::KeyMap, theme::Theme}; -pub mod constants; +pub mod env; pub mod theme; pub mod keymap; @@ -15,10 +14,6 @@ pub struct GlobalConfig { pub keymap: KeyMap, } -lazy_static! { - static ref GLOBAL_CONFIG: RwLock<GlobalConfig> = RwLock::new(GlobalConfig::new()); -} - const DUMMY_CONFIG: GlobalConfig = GlobalConfig::new(); impl GlobalConfig { @@ -29,12 +24,9 @@ impl GlobalConfig { } } - pub fn instance() -> RwLockReadGuard<'static, Self> { - GLOBAL_CONFIG.read().unwrap() - } - - pub fn instance_mut() -> RwLockWriteGuard<'static, Self> { - GLOBAL_CONFIG.write().unwrap() + pub fn get() -> &'static mut Self { + static mut GLOBAL_CONFIG: GlobalConfig = GlobalConfig::new(); + unsafe { &mut *addr_of_mut!(GLOBAL_CONFIG) } } } |