secp256k1: Remove custom implementations of Eq, Ord and friends
Now that we have Rust 1.48 as the MSRV we no longer need the custom implementations of `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash`. We can just let users of the `impl_array_newtype` macro derive these traits if they want them. Remove the custom implementations and add derives to our two users of the macro.
This commit is contained in:
parent
ee83c3a4f9
commit
a815272bfc
|
@ -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
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ impl<T: hashes::sha256t::Tag> ThirtyTwoByteHash for hashes::sha256t::Hash<T> {
|
|||
}
|
||||
|
||||
/// 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);
|
||||
|
|
|
@ -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<H: core::hash::Hasher>(&self, state: &mut H) { (&self[..]).hash(state) }
|
||||
}
|
||||
|
||||
impl PartialOrd for $thing {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &$thing) -> Option<core::cmp::Ordering> {
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue