Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jelte Fennema-Nio <github-tech@jeltef.nl>
  • Loading branch information
ModProg and JelteF committed Sep 16, 2023
1 parent 21b5faf commit dd33e43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions impl/doc/try_from.md
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ impl<T> TryFromReprError<T> {
}
}

// `T` should only be an integer type and therefor be debug
// `T` should only be an integer type and therefore be debug
impl<T: fmt::Debug> fmt::Display for TryFromReprError<T> {
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)
}
}

Expand Down

0 comments on commit dd33e43

Please sign in to comment.