diff options
Diffstat (limited to 'embassy-sync/src/mutex.rs')
| -rw-r--r-- | embassy-sync/src/mutex.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/embassy-sync/src/mutex.rs b/embassy-sync/src/mutex.rs index 7528a9f68..aea682899 100644 --- a/embassy-sync/src/mutex.rs +++ b/embassy-sync/src/mutex.rs | |||
| @@ -16,6 +16,7 @@ use crate::waitqueue::WakerRegistration; | |||
| 16 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 16 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 17 | pub struct TryLockError; | 17 | pub struct TryLockError; |
| 18 | 18 | ||
| 19 | #[derive(Debug)] | ||
| 19 | struct State { | 20 | struct State { |
| 20 | locked: bool, | 21 | locked: bool, |
| 21 | waker: WakerRegistration, | 22 | waker: WakerRegistration, |
| @@ -23,7 +24,7 @@ struct State { | |||
| 23 | 24 | ||
| 24 | /// Async mutex. | 25 | /// Async mutex. |
| 25 | /// | 26 | /// |
| 26 | /// The mutex is generic over a blocking [`RawMutex`](crate::blocking_mutex::raw::RawMutex). | 27 | /// The mutex is generic over a blocking [`RawMutex`]. |
| 27 | /// The raw mutex is used to guard access to the internal "is locked" flag. It | 28 | /// The raw mutex is used to guard access to the internal "is locked" flag. It |
| 28 | /// is held for very short periods only, while locking and unlocking. It is *not* held | 29 | /// is held for very short periods only, while locking and unlocking. It is *not* held |
| 29 | /// for the entire time the async Mutex is locked. | 30 | /// for the entire time the async Mutex is locked. |
| @@ -186,7 +187,7 @@ where | |||
| 186 | T: ?Sized, | 187 | T: ?Sized, |
| 187 | { | 188 | { |
| 188 | /// Returns a locked view over a portion of the locked data. | 189 | /// Returns a locked view over a portion of the locked data. |
| 189 | pub fn map<U>(this: Self, fun: impl FnOnce(&mut T) -> &mut U) -> MappedMutexGuard<'a, M, U> { | 190 | pub fn map<U: ?Sized>(this: Self, fun: impl FnOnce(&mut T) -> &mut U) -> MappedMutexGuard<'a, M, U> { |
| 190 | let mutex = this.mutex; | 191 | let mutex = this.mutex; |
| 191 | let value = fun(unsafe { &mut *this.mutex.inner.get() }); | 192 | let value = fun(unsafe { &mut *this.mutex.inner.get() }); |
| 192 | // Don't run the `drop` method for MutexGuard. The ownership of the underlying | 193 | // Don't run the `drop` method for MutexGuard. The ownership of the underlying |
| @@ -278,7 +279,7 @@ where | |||
| 278 | T: ?Sized, | 279 | T: ?Sized, |
| 279 | { | 280 | { |
| 280 | /// Returns a locked view over a portion of the locked data. | 281 | /// Returns a locked view over a portion of the locked data. |
| 281 | pub fn map<U>(this: Self, fun: impl FnOnce(&mut T) -> &mut U) -> MappedMutexGuard<'a, M, U> { | 282 | pub fn map<U: ?Sized>(this: Self, fun: impl FnOnce(&mut T) -> &mut U) -> MappedMutexGuard<'a, M, U> { |
| 282 | let state = this.state; | 283 | let state = this.state; |
| 283 | let value = fun(unsafe { &mut *this.value }); | 284 | let value = fun(unsafe { &mut *this.value }); |
| 284 | // Don't run the `drop` method for MutexGuard. The ownership of the underlying | 285 | // Don't run the `drop` method for MutexGuard. The ownership of the underlying |
