secp256k1-sys: Remove custom implementations of Eq, Ord and friends
Note: Only effects code when fuzzing is enabled, as such does not include a mention in the changelog. 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
a815272bfc
commit
7bba2bc3b5
|
@ -133,6 +133,7 @@ impl SchnorrSigExtraParams {
|
|||
/// Library-internal representation of a Secp256k1 public key
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||
pub struct PublicKey([c_uchar; 64]);
|
||||
impl_array_newtype!(PublicKey, c_uchar, 64);
|
||||
impl_raw_debug!(PublicKey);
|
||||
|
@ -227,6 +228,7 @@ impl core::hash::Hash for PublicKey {
|
|||
/// Library-internal representation of a Secp256k1 signature
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||
pub struct Signature([c_uchar; 64]);
|
||||
impl_array_newtype!(Signature, c_uchar, 64);
|
||||
impl_raw_debug!(Signature);
|
||||
|
@ -315,6 +317,7 @@ impl core::hash::Hash for Signature {
|
|||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||
pub struct XOnlyPublicKey([c_uchar; 64]);
|
||||
impl_array_newtype!(XOnlyPublicKey, c_uchar, 64);
|
||||
impl_raw_debug!(XOnlyPublicKey);
|
||||
|
@ -404,6 +407,7 @@ impl core::hash::Hash for XOnlyPublicKey {
|
|||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||
pub struct KeyPair([c_uchar; 96]);
|
||||
impl_array_newtype!(KeyPair, c_uchar, 96);
|
||||
impl_raw_debug!(KeyPair);
|
||||
|
|
|
@ -45,42 +45,6 @@ macro_rules! impl_array_newtype {
|
|||
}
|
||||
}
|
||||
|
||||
// We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`.
|
||||
|
||||
#[cfg(fuzzing)]
|
||||
impl PartialEq for $thing {
|
||||
#[inline]
|
||||
fn eq(&self, other: &$thing) -> bool {
|
||||
&self[..] == &other[..]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(fuzzing)]
|
||||
impl Eq for $thing {}
|
||||
|
||||
#[cfg(fuzzing)]
|
||||
impl core::hash::Hash for $thing {
|
||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||
(&self[..]).hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(fuzzing)]
|
||||
impl PartialOrd for $thing {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &$thing) -> Option<core::cmp::Ordering> {
|
||||
self[..].partial_cmp(&other[..])
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(fuzzing)]
|
||||
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
|
||||
|
|
|
@ -22,6 +22,7 @@ use core::fmt;
|
|||
/// Library-internal representation of a Secp256k1 signature + recovery ID
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
|
||||
pub struct RecoverableSignature([c_uchar; 65]);
|
||||
impl_array_newtype!(RecoverableSignature, c_uchar, 65);
|
||||
|
||||
|
|
Loading…
Reference in New Issue