diff options
Diffstat (limited to 'library/core/src/cell')
-rw-r--r-- | library/core/src/cell/once.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/library/core/src/cell/once.rs b/library/core/src/cell/once.rs index 5f06a7b07..2e8534f65 100644 --- a/library/core/src/cell/once.rs +++ b/library/core/src/cell/once.rs @@ -250,10 +250,12 @@ impl<T> Default for OnceCell<T> { #[stable(feature = "once_cell", since = "1.70.0")] impl<T: fmt::Debug> fmt::Debug for OnceCell<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut d = f.debug_tuple("OnceCell"); match self.get() { - Some(v) => f.debug_tuple("OnceCell").field(v).finish(), - None => f.write_str("OnceCell(Uninit)"), - } + Some(v) => d.field(v), + None => d.field(&format_args!("<uninit>")), + }; + d.finish() } } |