Skip to content

Commit 7165e61

Browse files
committed
std: fix Debug implementation on LazyLock
1 parent c1cced8 commit 7165e61

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

library/std/src/sync/lazy_lock.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use crate::mem::ManuallyDrop;
2-
31
use crate::cell::UnsafeCell;
42
use crate::fmt;
3+
use crate::mem::ManuallyDrop;
54
use crate::ops::Deref;
65
use crate::panic::{RefUnwindSafe, UnwindSafe};
76
use crate::sync::Once;
@@ -151,12 +150,10 @@ impl<T: Default> Default for LazyLock<T> {
151150
#[unstable(feature = "once_cell", issue = "74465")]
152151
impl<T: fmt::Debug, F> fmt::Debug for LazyLock<T, F> {
153152
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
154-
f.debug_tuple("LazyLock")
155-
.field(match self.get() {
156-
Some(v) => v,
157-
None => &"Uninit",
158-
})
159-
.finish()
153+
match self.get() {
154+
Some(v) => f.debug_tuple("LazyLock").field(v).finish(),
155+
None => f.write_str("LazyLock(Uninit)"),
156+
}
160157
}
161158
}
162159

0 commit comments

Comments
 (0)