From 8eaf21bf228b6d8a70c4082d7bb9bd1bfeff11fe Mon Sep 17 00:00:00 2001 From: Edoardo Morandi Date: Mon, 3 Nov 2025 15:42:16 +0100 Subject: [PATCH] feat: remove unnecessary unsafe The static with the lock does not actually requires to be mutable, because of the mutex itself. --- src/mustatex.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/mustatex.rs b/src/mustatex.rs index 7021eee..642eca7 100644 --- a/src/mustatex.rs +++ b/src/mustatex.rs @@ -7,20 +7,18 @@ macro_rules! mustatex { $viz mod $name { use super::*; - static mut INNER: std::sync::Mutex<$Type> = std::sync::Mutex::new($init); + static INNER: std::sync::Mutex<$Type> = std::sync::Mutex::new($init); pub fn set(x: $Type) { - unsafe { - *INNER.lock().unwrap() = x; - } + *INNER.lock().unwrap() = x; } pub fn get() -> impl std::ops::Deref { - unsafe { INNER.lock().unwrap() } + INNER.lock().unwrap() } pub fn get_mut() -> impl std::ops::DerefMut { - unsafe { INNER.lock().unwrap() } + INNER.lock().unwrap() } } )*