Skip to content

Commit eb23c1e

Browse files
committed
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`.
1 parent a025c7c commit eb23c1e

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

lightning/src/ln/msgs.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ pub use self::fuzzy_internal_msgs::*;
16751675
pub(crate) use self::fuzzy_internal_msgs::*;
16761676

16771677
/// BOLT 4 onion packet including hop data for the next peer.
1678-
#[derive(Clone)]
1678+
#[derive(Clone, PartialEq, Eq)]
16791679
pub struct OnionPacket {
16801680
/// BOLT 4 version number.
16811681
pub version: u8,
@@ -1703,18 +1703,6 @@ impl onion_utils::Packet for OnionPacket {
17031703
}
17041704
}
17051705

1706-
impl Eq for OnionPacket { }
1707-
impl PartialEq for OnionPacket {
1708-
fn eq(&self, other: &OnionPacket) -> bool {
1709-
for (i, j) in self.hop_data.iter().zip(other.hop_data.iter()) {
1710-
if i != j { return false; }
1711-
}
1712-
self.version == other.version &&
1713-
self.public_key == other.public_key &&
1714-
self.hmac == other.hmac
1715-
}
1716-
}
1717-
17181706
impl fmt::Debug for OnionPacket {
17191707
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17201708
f.write_fmt(format_args!("OnionPacket version {} with hmac {:?}", self.version, &self.hmac[..]))

0 commit comments

Comments
 (0)