From dd33e43437db3611545928378a9e0284e21a99ae Mon Sep 17 00:00:00 2001 From: Roland Fredenhagen Date: Sat, 16 Sep 2023 10:13:15 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Jelte Fennema-Nio --- impl/doc/try_from.md | 14 +++++++------- src/convert.rs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/impl/doc/try_from.md b/impl/doc/try_from.md index 385b483a..74c78cd0 100644 --- a/impl/doc/try_from.md +++ b/impl/doc/try_from.md @@ -13,15 +13,15 @@ Only field-less variants can be constructed from their variant, therefor the `Tr #[try_from(repr)] #[repr(u32)] enum Enum { - Implicit, - Explicit = 5, - Field(usize), - Empty{}, + ImplicitZero, + ExplicitFive = 5, + FieldSix(usize), + EmptySeven{}, } -assert_eq!(Enum::Implicit, Enum::try_from(0).unwrap()); -assert_eq!(Enum::Explicit, Enum::try_from(5).unwrap()); -assert_eq!(Enum::Empty{}, Enum::try_from(7).unwrap()); +assert_eq!(Enum::ImplicitZero, Enum::try_from(0).unwrap()); +assert_eq!(Enum::ExplicitFive, Enum::try_from(5).unwrap()); +assert_eq!(Enum::EmptySeven{}, Enum::try_from(7).unwrap()); // Variants with fields are not supported, as the value for their fields would be undefined. assert!(Enum::try_from(6).is_err()); diff --git a/src/convert.rs b/src/convert.rs index 7b5aa15c..0251a17f 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -68,10 +68,10 @@ impl TryFromReprError { } } -// `T` should only be an integer type and therefor be debug +// `T` should only be an integer type and therefore 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 corespond to a unit variant", self.input) } }