diff --git a/CHANGELOG.md b/CHANGELOG.md index b9337ba..703b45b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Unreleased * Bump MSRV to 1.48 +* Remove implementations of `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash` from the + `impl_array_newtype` macro. Users will now need to derive these traits if they are wanted. # 0.27.0 - 2023-03-15 diff --git a/src/lib.rs b/src/lib.rs index 9abcf39..ea72ae1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -232,7 +232,7 @@ impl ThirtyTwoByteHash for hashes::sha256t::Hash { } /// A (hashed) message input to an ECDSA signature. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Message([u8; constants::MESSAGE_SIZE]); impl_array_newtype!(Message, u8, constants::MESSAGE_SIZE); impl_pretty_debug!(Message); diff --git a/src/macros.rs b/src/macros.rs index 16672da..d5b78e9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -17,31 +17,6 @@ #[macro_export] macro_rules! impl_array_newtype { ($thing:ident, $ty:ty, $len:expr) => { - // We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`. - - impl PartialEq for $thing { - #[inline] - fn eq(&self, other: &$thing) -> bool { &self[..] == &other[..] } - } - - impl Eq for $thing {} - - impl core::hash::Hash for $thing { - fn hash(&self, state: &mut H) { (&self[..]).hash(state) } - } - - impl PartialOrd for $thing { - #[inline] - fn partial_cmp(&self, other: &$thing) -> Option { - self[..].partial_cmp(&other[..]) - } - } - - impl Ord for $thing { - #[inline] - fn cmp(&self, other: &$thing) -> core::cmp::Ordering { self[..].cmp(&other[..]) } - } - impl AsRef<[$ty; $len]> for $thing { #[inline] /// Gets a reference to the underlying array diff --git a/src/schnorr.rs b/src/schnorr.rs index 1a79893..6aed26b 100644 --- a/src/schnorr.rs +++ b/src/schnorr.rs @@ -15,7 +15,7 @@ use crate::{ }; /// Represents a schnorr signature. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Signature([u8; constants::SCHNORR_SIGNATURE_SIZE]); impl_array_newtype!(Signature, u8, constants::SCHNORR_SIGNATURE_SIZE); impl_pretty_debug!(Signature);