Rely on const generic big arrays for `PartialEq` in msgs
authorMatt Corallo <git@bluematt.me>
Mon, 13 Nov 2023 22:48:48 +0000 (22:48 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 14 Nov 2023 00:40:30 +0000 (00:40 +0000)
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

index d43ad6d0aebc2fd372c5c7837349a9beac0ebedf..47a98f734f011f7201770b212b2261f660a2afad 100644 (file)
@@ -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[..]))