about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorPeter Todd <pete@petertodd.org>2019-11-07 08:50:18 -0500
committerPeter Todd <pete@petertodd.org>2019-11-07 08:50:18 -0500
commit8fad66b43151c5c1bbb7933e54051ae8c11fe595 (patch)
tree8142fcd43f266986883261da294da4eceba8c324 /src/libcore
parent87cbf0a547aaf9e8a7fc708851ecf4bc2adab5fd (diff)
downloadrust-8fad66b43151c5c1bbb7933e54051ae8c11fe595.tar.gz
rust-8fad66b43151c5c1bbb7933e54051ae8c11fe595.zip
Implement Debug for MaybeUninit
Precedent: UnsafeCell implements Debug even though it can't actually
display the value.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/mem/maybe_uninit.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs
index 792ce9dfad4..36c7160229a 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<T: Copy> Clone for MaybeUninit<T> {
     }
 }
 
+#[stable(feature = "maybe_uninit_debug", since = "1.41.0")]
+impl<T> fmt::Debug for MaybeUninit<T> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.pad(type_name::<Self>())
+    }
+}
+
 impl<T> MaybeUninit<T> {
     /// Creates a new `MaybeUninit<T>` initialized with the given value.
     /// It is safe to call [`assume_init`] on the return value of this function.