diff options
| author | Dion Dokter <[email protected]> | 2022-06-16 12:36:39 +0200 |
|---|---|---|
| committer | Dion Dokter <[email protected]> | 2022-06-16 12:36:39 +0200 |
| commit | 03996583a1811fd6926d0f5e4115b6165cbceda0 (patch) | |
| tree | d2be89005fc69906ad7d4d08ee4a329667737f59 | |
| parent | 12a6ddfbcd79f2ab62ba264acd997dca0ac64a99 (diff) | |
fmt
| -rw-r--r-- | embassy/src/channel/pubsub.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/embassy/src/channel/pubsub.rs b/embassy/src/channel/pubsub.rs index 5e5cce9cf..fb8d0ef5f 100644 --- a/embassy/src/channel/pubsub.rs +++ b/embassy/src/channel/pubsub.rs | |||
| @@ -25,7 +25,9 @@ pub struct PubSubChannel<M: RawMutex, T: Clone, const CAP: usize, const SUBS: us | |||
| 25 | inner: Mutex<M, RefCell<PubSubState<T, CAP, SUBS, PUBS>>>, | 25 | inner: Mutex<M, RefCell<PubSubState<T, CAP, SUBS, PUBS>>>, |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> PubSubChannel<M, T, CAP, SUBS, PUBS> { | 28 | impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> |
| 29 | PubSubChannel<M, T, CAP, SUBS, PUBS> | ||
| 30 | { | ||
| 29 | /// Create a new channel | 31 | /// Create a new channel |
| 30 | pub const fn new() -> Self { | 32 | pub const fn new() -> Self { |
| 31 | Self { | 33 | Self { |
| @@ -134,7 +136,7 @@ impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usi | |||
| 134 | // We are going to call something is Self again. | 136 | // We are going to call something is Self again. |
| 135 | // The lock is fine, but we need to get rid of the refcell borrow | 137 | // The lock is fine, but we need to get rid of the refcell borrow |
| 136 | drop(s); | 138 | drop(s); |
| 137 | 139 | ||
| 138 | // This will succeed because we made sure there is space | 140 | // This will succeed because we made sure there is space |
| 139 | unsafe { self.try_publish(message).unwrap_unchecked() }; | 141 | unsafe { self.try_publish(message).unwrap_unchecked() }; |
| 140 | }); | 142 | }); |
| @@ -354,7 +356,6 @@ impl<'a, T: Clone> ImmediatePublisher<'a, T> { | |||
| 354 | pub fn try_publish(&self, message: T) -> Result<(), T> { | 356 | pub fn try_publish(&self, message: T) -> Result<(), T> { |
| 355 | self.channel.try_publish(message) | 357 | self.channel.try_publish(message) |
| 356 | } | 358 | } |
| 357 | |||
| 358 | } | 359 | } |
| 359 | 360 | ||
| 360 | /// Error type for the [PubSubChannel] | 361 | /// Error type for the [PubSubChannel] |
| @@ -480,8 +481,8 @@ pub enum WaitResult<T> { | |||
| 480 | 481 | ||
| 481 | #[cfg(test)] | 482 | #[cfg(test)] |
| 482 | mod tests { | 483 | mod tests { |
| 483 | use crate::blocking_mutex::raw::NoopRawMutex; | ||
| 484 | use super::*; | 484 | use super::*; |
| 485 | use crate::blocking_mutex::raw::NoopRawMutex; | ||
| 485 | 486 | ||
| 486 | #[futures_test::test] | 487 | #[futures_test::test] |
| 487 | async fn all_subscribers_receive() { | 488 | async fn all_subscribers_receive() { |
| @@ -586,5 +587,4 @@ mod tests { | |||
| 586 | 587 | ||
| 587 | drop(sub0); | 588 | drop(sub0); |
| 588 | } | 589 | } |
| 589 | |||
| 590 | } | 590 | } |
