From 9a63f3ee714bee35612e1af3d29c82d69d8a9f82 Mon Sep 17 00:00:00 2001 From: Roland Fredenhagen Date: Sat, 9 Sep 2023 14:37:53 +0200 Subject: [PATCH] Rename `TryFromError` to `TryFromReprError` --- impl/src/try_from.rs | 2 +- src/convert.rs | 17 +++++++++-------- src/lib.rs | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/impl/src/try_from.rs b/impl/src/try_from.rs index 8cd081bb..fee25d6e 100644 --- a/impl/src/try_from.rs +++ b/impl/src/try_from.rs @@ -165,7 +165,7 @@ impl ToTokens for Expansion { ::core::convert::TryFrom<#repr #ty_generics> for #ident #where_clause { - type Error = ::derive_more::TryFromError<#repr>; + type Error = ::derive_more::TryFromReprError<#repr>; #[inline] fn try_from(value: #repr) -> ::core::result::Result { diff --git a/src/convert.rs b/src/convert.rs index 7b06ed0a..7b5aa15c 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -46,11 +46,12 @@ impl fmt::Display for TryIntoError { #[cfg(feature = "std")] impl std::error::Error for TryIntoError {} -/// Error returned by the derived [`TryFrom`] implementation. +/// Error returned by the derived [`TryFrom`] implementation on enums to +/// convert from their repr. /// /// [`TryFrom`]: macro@crate::TryFrom #[derive(Clone, Copy, Debug)] -pub struct TryFromError { +pub struct TryFromReprError { /// Original input value which failed to convert via the derived /// [`TryFrom`] implementation. /// @@ -58,7 +59,7 @@ pub struct TryFromError { pub input: T, } -impl TryFromError { +impl TryFromReprError { #[doc(hidden)] #[must_use] #[inline] @@ -67,13 +68,13 @@ impl TryFromError { } } -// `T` should only be an integer type and therefor display -impl fmt::Display for TryFromError { +// `T` should only be an integer type and therefor be debug +impl fmt::Display for TryFromReprError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "`{}` does not respond to a unit variant", self.input) + write!(f, "`{:?}` does not respond to a unit variant", self.input) } } #[cfg(feature = "std")] -// `T` should only be an integer type and therefor display and debug -impl std::error::Error for TryFromError {} +// `T` should only be an integer type and therefor be debug +impl std::error::Error for TryFromReprError {} diff --git a/src/lib.rs b/src/lib.rs index 7c687375..831e6523 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,7 @@ pub use crate::r#str::FromStrError; mod convert; #[cfg(feature = "try_from")] #[doc(inline)] -pub use crate::convert::TryFromError; +pub use crate::convert::TryFromReprError; #[cfg(feature = "try_into")] #[doc(inline)] pub use crate::convert::TryIntoError;