Implement Ord for arrays
This commit is contained in:
parent
01fb30502a
commit
b192157ab4
|
@ -49,10 +49,9 @@ pub const ONE_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 1]);
|
0, 0, 0, 0, 0, 0, 0, 1]);
|
||||||
|
|
||||||
/// A Secp256k1 public key, used for verification of signatures
|
/// A Secp256k1 public key, used for verification of signatures
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug, PartialOrd, Ord, Hash)]
|
||||||
pub struct PublicKey(ffi::PublicKey);
|
pub struct PublicKey(ffi::PublicKey);
|
||||||
|
|
||||||
|
|
||||||
#[cfg(any(test, feature = "rand"))]
|
#[cfg(any(test, feature = "rand"))]
|
||||||
fn random_32_bytes<R: Rng>(rng: &mut R) -> [u8; 32] {
|
fn random_32_bytes<R: Rng>(rng: &mut R) -> [u8; 32] {
|
||||||
let mut ret = [0u8; 32];
|
let mut ret = [0u8; 32];
|
||||||
|
|
|
@ -51,6 +51,20 @@ macro_rules! impl_array_newtype {
|
||||||
|
|
||||||
impl Eq for $thing {}
|
impl Eq for $thing {}
|
||||||
|
|
||||||
|
impl PartialOrd for $thing {
|
||||||
|
#[inline]
|
||||||
|
fn partial_cmp(&self, other: &$thing) -> Option<::std::cmp::Ordering> {
|
||||||
|
self[..].partial_cmp(&other[..])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for $thing {
|
||||||
|
#[inline]
|
||||||
|
fn cmp(&self, other: &$thing) -> ::std::cmp::Ordering {
|
||||||
|
self[..].cmp(&other[..])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Clone for $thing {
|
impl Clone for $thing {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn clone(&self) -> $thing {
|
fn clone(&self) -> $thing {
|
||||||
|
|
Loading…
Reference in New Issue