diff options
Diffstat (limited to 'embassy-sync/src/once_lock.rs')
| -rw-r--r-- | embassy-sync/src/once_lock.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/embassy-sync/src/once_lock.rs b/embassy-sync/src/once_lock.rs index 55608ba32..cd05b986d 100644 --- a/embassy-sync/src/once_lock.rs +++ b/embassy-sync/src/once_lock.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | //! Synchronization primitive for initializing a value once, allowing others to await a reference to the value. | 1 | //! Synchronization primitive for initializing a value once, allowing others to await a reference to the value. |
| 2 | 2 | ||
| 3 | use core::cell::Cell; | 3 | use core::cell::Cell; |
| 4 | use core::future::poll_fn; | 4 | use core::future::{poll_fn, Future}; |
| 5 | use core::mem::MaybeUninit; | 5 | use core::mem::MaybeUninit; |
| 6 | use core::sync::atomic::{AtomicBool, Ordering}; | 6 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 7 | use core::task::Poll; | 7 | use core::task::Poll; |
| @@ -55,7 +55,7 @@ impl<T> OnceLock<T> { | |||
| 55 | 55 | ||
| 56 | /// Get a reference to the underlying value, waiting for it to be set. | 56 | /// Get a reference to the underlying value, waiting for it to be set. |
| 57 | /// If the value is already set, this will return immediately. | 57 | /// If the value is already set, this will return immediately. |
| 58 | pub async fn get(&self) -> &T { | 58 | pub fn get(&self) -> impl Future<Output = &T> { |
| 59 | poll_fn(|cx| match self.try_get() { | 59 | poll_fn(|cx| match self.try_get() { |
| 60 | Some(data) => Poll::Ready(data), | 60 | Some(data) => Poll::Ready(data), |
| 61 | None => { | 61 | None => { |
| @@ -63,7 +63,6 @@ impl<T> OnceLock<T> { | |||
| 63 | Poll::Pending | 63 | Poll::Pending |
| 64 | } | 64 | } |
| 65 | }) | 65 | }) |
| 66 | .await | ||
| 67 | } | 66 | } |
| 68 | 67 | ||
| 69 | /// Try to get a reference to the underlying value if it exists. | 68 | /// Try to get a reference to the underlying value if it exists. |
