Skip to content

Commit

Permalink
TryFromPrimitiveError: Derive a bunch of traits
Browse files Browse the repository at this point in the history
I'm not sure why we were manually implementing these, but we don't need
to, and clippy on nightly has started complaining about the Clone impl.
  • Loading branch information
illicitonion committed Jul 7, 2023
1 parent 66d22cc commit 71c1675
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions num_enum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,11 @@ pub trait UnsafeFromPrimitive: Sized {
unsafe fn unchecked_transmute_from(number: Self::Primitive) -> Self;
}

#[derive(Copy, Clone, PartialEq, Eq)]
pub struct TryFromPrimitiveError<Enum: TryFromPrimitive> {
pub number: Enum::Primitive,
}

impl<Enum: TryFromPrimitive> Copy for TryFromPrimitiveError<Enum> {}
impl<Enum: TryFromPrimitive> Clone for TryFromPrimitiveError<Enum> {
fn clone(&self) -> Self {
TryFromPrimitiveError {
number: self.number,
}
}
}
impl<Enum: TryFromPrimitive> Eq for TryFromPrimitiveError<Enum> {}
impl<Enum: TryFromPrimitive> PartialEq for TryFromPrimitiveError<Enum> {
fn eq(&self, other: &Self) -> bool {
self.number == other.number
}
}
impl<Enum: TryFromPrimitive> fmt::Debug for TryFromPrimitiveError<Enum> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("TryFromPrimitiveError")
Expand Down

0 comments on commit 71c1675

Please sign in to comment.