From 86c88bea1247c7f89c9d1bb4c4a424a7b1f5abaf Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 23 Jan 2021 22:48:54 -0800 Subject: [PATCH] Hide some irrelevant detail from de::value::Error's Debug impl --- serde/src/de/value.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/serde/src/de/value.rs b/serde/src/de/value.rs index a3f8cbd3..207f93e3 100644 --- a/serde/src/de/value.rs +++ b/serde/src/de/value.rs @@ -48,7 +48,7 @@ macro_rules! impl_copy_clone { /// A minimal representation of all possible errors that can occur using the /// `IntoDeserializer` trait. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, PartialEq)] pub struct Error { err: ErrorImpl, } @@ -103,6 +103,15 @@ impl Display for Error { } } +impl Debug for Error { + fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + let mut debug = formatter.debug_tuple("Error"); + #[cfg(any(feature = "std", feature = "alloc"))] + debug.field(&self.err); + debug.finish() + } +} + #[cfg(feature = "std")] impl error::Error for Error { fn description(&self) -> &str {