From eb23c1e43b0372e53c0b19b1eeafebeef50d2089 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 13 Nov 2023 22:48:48 +0000 Subject: [PATCH] Rely on const generic big arrays for `PartialEq` in msgs Implementation of standard traits on arrays longer than 32 elements was shipped in rustc 1.47, which is below our MSRV of 1.48 and we can use to remove some unnecessary manual implementation of `PartialEq` on `OnionPacket`. --- lightning/src/ln/msgs.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index d43ad6d0a..47a98f734 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -1675,7 +1675,7 @@ pub use self::fuzzy_internal_msgs::*; pub(crate) use self::fuzzy_internal_msgs::*; /// BOLT 4 onion packet including hop data for the next peer. -#[derive(Clone)] +#[derive(Clone, PartialEq, Eq)] pub struct OnionPacket { /// BOLT 4 version number. pub version: u8, @@ -1703,18 +1703,6 @@ impl onion_utils::Packet for OnionPacket { } } -impl Eq for OnionPacket { } -impl PartialEq for OnionPacket { - fn eq(&self, other: &OnionPacket) -> bool { - for (i, j) in self.hop_data.iter().zip(other.hop_data.iter()) { - if i != j { return false; } - } - self.version == other.version && - self.public_key == other.public_key && - self.hmac == other.hmac - } -} - impl fmt::Debug for OnionPacket { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_fmt(format_args!("OnionPacket version {} with hmac {:?}", self.version, &self.hmac[..])) -- 2.39.5