diff options
| author | huntc <[email protected]> | 2021-07-11 12:05:50 +1000 |
|---|---|---|
| committer | huntc <[email protected]> | 2021-07-15 12:31:52 +1000 |
| commit | 5a5795ef2b25fe227978935a1d5b2efb3cf5b08c (patch) | |
| tree | 358eb0c7ba89ceec8a31b74a092856b35f64be66 | |
| parent | 9b5f2e465bf97300664263cedecd9b8d8034d435 (diff) | |
NoopMutex does not require an UnsafeCell
| -rw-r--r-- | embassy/src/util/mutex.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/embassy/src/util/mutex.rs b/embassy/src/util/mutex.rs index db3423cb3..c8fe84026 100644 --- a/embassy/src/util/mutex.rs +++ b/embassy/src/util/mutex.rs | |||
| @@ -108,20 +108,18 @@ pub fn in_thread_mode() -> bool { | |||
| 108 | 108 | ||
| 109 | /// A "mutex" that does nothing and cannot be shared between threads. | 109 | /// A "mutex" that does nothing and cannot be shared between threads. |
| 110 | pub struct NoopMutex<T> { | 110 | pub struct NoopMutex<T> { |
| 111 | inner: UnsafeCell<T>, | 111 | inner: T, |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | impl<T> NoopMutex<T> { | 114 | impl<T> NoopMutex<T> { |
| 115 | pub const fn new(value: T) -> Self { | 115 | pub const fn new(value: T) -> Self { |
| 116 | NoopMutex { | 116 | NoopMutex { inner: value } |
| 117 | inner: UnsafeCell::new(value), | ||
| 118 | } | ||
| 119 | } | 117 | } |
| 120 | } | 118 | } |
| 121 | 119 | ||
| 122 | impl<T> NoopMutex<T> { | 120 | impl<T> NoopMutex<T> { |
| 123 | pub fn borrow(&self) -> &T { | 121 | pub fn borrow(&self) -> &T { |
| 124 | unsafe { &*self.inner.get() } | 122 | &self.inner |
| 125 | } | 123 | } |
| 126 | } | 124 | } |
| 127 | 125 | ||
