diff options
Diffstat (limited to 'src/libstd/error.rs')
| -rw-r--r-- | src/libstd/error.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 7cb830e751a..9424e059a14 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -300,7 +300,6 @@ impl From<String> for Box<dyn Error + Send + Sync> { /// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error)) /// ``` fn from(err: String) -> Box<dyn Error + Send + Sync> { - #[derive(Debug)] struct StringError(String); impl Error for StringError { @@ -313,6 +312,13 @@ impl From<String> for Box<dyn Error + Send + Sync> { } } + // Purposefully skip printing "StringError(..)" + impl Debug for StringError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + Debug::fmt(&self.0, f) + } + } + Box::new(StringError(err)) } } |
