std: fix Debug implementation on LazyLock

This commit is contained in:
joboet 2023-01-27 10:09:38 +01:00
parent c1cced8d04
commit 7165e610a2
No known key found for this signature in database
GPG Key ID: 704E0149B0194B3C

View File

@ -1,7 +1,6 @@
use crate::mem::ManuallyDrop;
use crate::cell::UnsafeCell;
use crate::fmt;
use crate::mem::ManuallyDrop;
use crate::ops::Deref;
use crate::panic::{RefUnwindSafe, UnwindSafe};
use crate::sync::Once;
@ -151,12 +150,10 @@ fn default() -> LazyLock<T> {
#[unstable(feature = "once_cell", issue = "74465")]
impl<T: fmt::Debug, F> fmt::Debug for LazyLock<T, F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("LazyLock")
.field(match self.get() {
Some(v) => v,
None => &"Uninit",
})
.finish()
match self.get() {
Some(v) => f.debug_tuple("LazyLock").field(v).finish(),
None => f.write_str("LazyLock(Uninit)"),
}
}
}