From 8fad66b43151c5c1bbb7933e54051ae8c11fe595 Mon Sep 17 00:00:00 2001 From: Peter Todd Date: Thu, 7 Nov 2019 08:50:18 -0500 Subject: [PATCH] Implement Debug for MaybeUninit Precedent: UnsafeCell implements Debug even though it can't actually display the value. --- src/libcore/mem/maybe_uninit.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 792ce9dfad419..36c7160229ab8 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -1,3 +1,5 @@ +use crate::any::type_name; +use crate::fmt; use crate::intrinsics; use crate::mem::ManuallyDrop; @@ -230,6 +232,13 @@ impl Clone for MaybeUninit { } } +#[stable(feature = "maybe_uninit_debug", since = "1.41.0")] +impl fmt::Debug for MaybeUninit { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.pad(type_name::()) + } +} + impl MaybeUninit { /// Creates a new `MaybeUninit` initialized with the given value. /// It is safe to call [`assume_init`] on the return value of this function.