diff options
| author | Curly <[email protected]> | 2025-08-19 22:30:53 -0700 |
|---|---|---|
| committer | Curly <[email protected]> | 2025-08-19 22:36:49 -0700 |
| commit | 368738bef44dbba1a178383d878a6d9423b1ccd9 (patch) | |
| tree | 4c375e7ec4615e6dee9fda837584067d19b7caf6 /embassy-sync/src/once_lock.rs | |
| parent | a5cb04bdab602bc3bd056d254a9d61cad55bd967 (diff) | |
chore: add more `Debug` impls to `embassy-sync`, particularly on `OnceLock`
All tests green
Diffstat (limited to 'embassy-sync/src/once_lock.rs')
| -rw-r--r-- | embassy-sync/src/once_lock.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/embassy-sync/src/once_lock.rs b/embassy-sync/src/once_lock.rs index 1e848685a..73edfea9a 100644 --- a/embassy-sync/src/once_lock.rs +++ b/embassy-sync/src/once_lock.rs | |||
| @@ -1,6 +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::fmt::{Debug, Formatter}; | ||
| 4 | use core::future::{poll_fn, Future}; | 5 | use core::future::{poll_fn, Future}; |
| 5 | use core::mem::MaybeUninit; | 6 | use core::mem::MaybeUninit; |
| 6 | use core::sync::atomic::{AtomicBool, Ordering}; | 7 | use core::sync::atomic::{AtomicBool, Ordering}; |
| @@ -42,6 +43,15 @@ pub struct OnceLock<T> { | |||
| 42 | data: Cell<MaybeUninit<T>>, | 43 | data: Cell<MaybeUninit<T>>, |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 46 | impl<T> Debug for OnceLock<T> { | ||
| 47 | fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { | ||
| 48 | f.debug_struct("OnceLock") | ||
| 49 | .field("init", &self.init) | ||
| 50 | .field("data", &"Cell<MaybeUninit<{unprintable}>>") | ||
| 51 | .finish() | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 45 | unsafe impl<T> Sync for OnceLock<T> where T: Sync {} | 55 | unsafe impl<T> Sync for OnceLock<T> where T: Sync {} |
| 46 | 56 | ||
| 47 | impl<T> OnceLock<T> { | 57 | impl<T> OnceLock<T> { |
