Skip to content

Commit 7d298ed

Browse files
Remove use of let_chains
They won't be stabilized in 1.64 :(
1 parent 6a7cb8b commit 7d298ed

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/packet.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,19 @@ impl<'a, V: IpVersion> EchoReplyPacket<'a, V> {
8080
/// Parse an IP packet containing an ICMP echo reply packet
8181
pub(crate) fn from_reply(source: V, buf: Cow<'a, [u8]>) -> Option<Self> {
8282
if V::IS_V4 {
83-
if let Some(ip_packet) = Ipv4Packet::new(&buf) && let Some(icmp_packet) = IcmpPacket::new(ip_packet.payload()) && icmp_packet.get_icmp_type() == IcmpTypes::EchoReply {
83+
if let Some(ip_packet) = Ipv4Packet::new(&buf) {
84+
if let Some(icmp_packet) = IcmpPacket::new(ip_packet.payload()) {
85+
if icmp_packet.get_icmp_type() == IcmpTypes::EchoReply {
86+
// SAFETY: we just checked that the packet is valid
87+
return Some(unsafe { Self::from_reply_unchecked(source, buf) });
88+
}
89+
}
90+
}
91+
} else if let Some(icmp_packet) = Icmpv6Packet::new(&buf) {
92+
if icmp_packet.get_icmpv6_type() == Icmpv6Types::EchoReply {
8493
// SAFETY: we just checked that the packet is valid
8594
return Some(unsafe { Self::from_reply_unchecked(source, buf) });
86-
}
87-
} else if let Some(icmp_packet) = Icmpv6Packet::new(&buf) && icmp_packet.get_icmpv6_type() == Icmpv6Types::EchoReply {
88-
// SAFETY: we just checked that the packet is valid
89-
return Some(unsafe { Self::from_reply_unchecked(source, buf) });
95+
}
9096
}
9197

9298
None

0 commit comments

Comments
 (0)