From 5a5795ef2b25fe227978935a1d5b2efb3cf5b08c Mon Sep 17 00:00:00 2001 From: huntc Date: Sun, 11 Jul 2021 12:05:50 +1000 Subject: [PATCH] NoopMutex does not require an UnsafeCell --- embassy/src/util/mutex.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/embassy/src/util/mutex.rs b/embassy/src/util/mutex.rs index db3423cb..c8fe8402 100644 --- a/embassy/src/util/mutex.rs +++ b/embassy/src/util/mutex.rs @@ -108,20 +108,18 @@ pub fn in_thread_mode() -> bool { /// A "mutex" that does nothing and cannot be shared between threads. pub struct NoopMutex { - inner: UnsafeCell, + inner: T, } impl NoopMutex { pub const fn new(value: T) -> Self { - NoopMutex { - inner: UnsafeCell::new(value), - } + NoopMutex { inner: value } } } impl NoopMutex { pub fn borrow(&self) -> &T { - unsafe { &*self.inner.get() } + &self.inner } }