From e55c1f0960a7ede1e2f33831119c6e9361d55e90 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Tue, 31 Oct 2023 19:57:26 +0100 Subject: [PATCH] Implement `Ord` for `SerializedSignature` --- src/ecdsa/serialized_signature.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/ecdsa/serialized_signature.rs b/src/ecdsa/serialized_signature.rs index bfd035f2d..8cf2c0294 100644 --- a/src/ecdsa/serialized_signature.rs +++ b/src/ecdsa/serialized_signature.rs @@ -53,6 +53,28 @@ impl PartialEq for [u8] { fn eq(&self, other: &SerializedSignature) -> bool { *self == **other } } +impl PartialOrd for SerializedSignature { + fn partial_cmp(&self, other: &SerializedSignature) -> Option { + Some((**self).cmp(&**other)) + } +} + +impl Ord for SerializedSignature { + fn cmp(&self, other: &SerializedSignature) -> core::cmp::Ordering { (**self).cmp(&**other) } +} + +impl PartialOrd<[u8]> for SerializedSignature { + fn partial_cmp(&self, other: &[u8]) -> Option { + (**self).partial_cmp(other) + } +} + +impl PartialOrd for [u8] { + fn partial_cmp(&self, other: &SerializedSignature) -> Option { + self.partial_cmp(&**other) + } +} + impl core::hash::Hash for SerializedSignature { fn hash(&self, state: &mut H) { (**self).hash(state) } }