aboutsummaryrefslogtreecommitdiff
path: root/embassy-sync/src/once_lock.rs
diff options
context:
space:
mode:
authorCurly <[email protected]>2025-08-19 22:30:53 -0700
committerCurly <[email protected]>2025-08-19 22:36:49 -0700
commit368738bef44dbba1a178383d878a6d9423b1ccd9 (patch)
tree4c375e7ec4615e6dee9fda837584067d19b7caf6 /embassy-sync/src/once_lock.rs
parenta5cb04bdab602bc3bd056d254a9d61cad55bd967 (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.rs10
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
3use core::cell::Cell; 3use core::cell::Cell;
4use core::fmt::{Debug, Formatter};
4use core::future::{poll_fn, Future}; 5use core::future::{poll_fn, Future};
5use core::mem::MaybeUninit; 6use core::mem::MaybeUninit;
6use core::sync::atomic::{AtomicBool, Ordering}; 7use 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
46impl<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
45unsafe impl<T> Sync for OnceLock<T> where T: Sync {} 55unsafe impl<T> Sync for OnceLock<T> where T: Sync {}
46 56
47impl<T> OnceLock<T> { 57impl<T> OnceLock<T> {