Browse Source

Merge #728

728: Clippy fixes. r=Dirbaio a=Dirbaio

bors r+

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
bors[bot] 2 years ago
parent
commit
b07707dd52

+ 1 - 1
src/iface/fragmentation.rs

@@ -43,7 +43,7 @@ impl fmt::Display for AssemblerState {
                 expires_at,
                 offset_correction,
             } => {
-                write!(f, "{} expires at {}", assembler, expires_at)?;
+                write!(f, "{assembler} expires at {expires_at}")?;
             }
         }
         Ok(())

+ 2 - 2
src/iface/interface/mod.rs

@@ -1747,11 +1747,11 @@ impl<'a> InterfaceInner<'a> {
     }
 
     #[cfg(feature = "socket-raw")]
-    fn raw_socket_filter<'frame>(
+    fn raw_socket_filter(
         &mut self,
         sockets: &mut SocketSet,
         ip_repr: &IpRepr,
-        ip_payload: &'frame [u8],
+        ip_payload: &[u8],
     ) -> bool {
         let mut handled_by_raw_socket = false;
 

+ 1 - 1
src/parsers.rs

@@ -95,7 +95,7 @@ impl<'a> Parser<'a> {
 
     fn accept_digit(&mut self, hex: bool) -> Result<u8> {
         let digit = self.advance()?;
-        if (b'0'..=b'9').contains(&digit) {
+        if digit.is_ascii_digit() {
             Ok(digit - b'0')
         } else if hex && (b'a'..=b'f').contains(&digit) {
             Ok(digit - b'a' + 10)

+ 2 - 2
src/phy/fault_injector.rs

@@ -138,12 +138,12 @@ impl<D: Device> FaultInjector<D> {
 
     /// Return the maximum packet transmission rate, in packets per second.
     pub fn max_tx_rate(&self) -> u64 {
-        self.config.max_rx_rate
+        self.config.max_tx_rate
     }
 
     /// Return the maximum packet reception rate, in packets per second.
     pub fn max_rx_rate(&self) -> u64 {
-        self.config.max_tx_rate
+        self.config.max_rx_rate
     }
 
     /// Return the interval for packet rate limiting, in milliseconds.

+ 1 - 1
src/storage/assembler.rs

@@ -108,7 +108,7 @@ impl fmt::Display for Assembler {
             if contig.is_empty() {
                 break;
             }
-            write!(f, "{} ", contig)?;
+            write!(f, "{contig} ")?;
         }
         write!(f, "]")?;
         Ok(())

+ 4 - 9
src/wire/arp.rs

@@ -322,7 +322,7 @@ impl Repr {
 impl<T: AsRef<[u8]>> fmt::Display for Packet<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self) {
-            Ok(repr) => write!(f, "{}", repr),
+            Ok(repr) => write!(f, "{repr}"),
             _ => {
                 write!(f, "ARP (unrecognized)")?;
                 write!(
@@ -360,12 +360,7 @@ impl fmt::Display for Repr {
             } => {
                 write!(
                     f,
-                    "ARP type=Ethernet+IPv4 src={}/{} tgt={}/{} op={:?}",
-                    source_hardware_addr,
-                    source_protocol_addr,
-                    target_hardware_addr,
-                    target_protocol_addr,
-                    operation
+                    "ARP type=Ethernet+IPv4 src={source_hardware_addr}/{source_protocol_addr} tgt={target_hardware_addr}/{target_protocol_addr} op={operation:?}"
                 )
             }
         }
@@ -381,8 +376,8 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
         indent: &mut PrettyIndent,
     ) -> fmt::Result {
         match Packet::new_checked(buffer) {
-            Err(err) => write!(f, "{}({})", indent, err),
-            Ok(packet) => write!(f, "{}{}", indent, packet),
+            Err(err) => write!(f, "{indent}({err})"),
+            Ok(packet) => write!(f, "{indent}{packet}"),
         }
     }
 }

+ 3 - 3
src/wire/ethernet.rs

@@ -18,7 +18,7 @@ impl fmt::Display for EtherType {
             EtherType::Ipv4 => write!(f, "IPv4"),
             EtherType::Ipv6 => write!(f, "IPv6"),
             EtherType::Arp => write!(f, "ARP"),
-            EtherType::Unknown(id) => write!(f, "0x{:04x}", id),
+            EtherType::Unknown(id) => write!(f, "0x{id:04x}"),
         }
     }
 }
@@ -230,10 +230,10 @@ impl<T: AsRef<[u8]>> PrettyPrint for Frame<T> {
         indent: &mut PrettyIndent,
     ) -> fmt::Result {
         let frame = match Frame::new_checked(buffer) {
-            Err(err) => return write!(f, "{}({})", indent, err),
+            Err(err) => return write!(f, "{indent}({err})"),
             Ok(frame) => frame,
         };
-        write!(f, "{}{}", indent, frame)?;
+        write!(f, "{indent}{frame}")?;
 
         match frame.ethertype() {
             #[cfg(feature = "proto-ipv4")]

+ 9 - 9
src/wire/icmpv4.rs

@@ -45,7 +45,7 @@ impl fmt::Display for Message {
             Message::ParamProblem => write!(f, "parameter problem"),
             Message::Timestamp => write!(f, "timestamp"),
             Message::TimestampReply => write!(f, "timestamp reply"),
-            Message::Unknown(id) => write!(f, "{}", id),
+            Message::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -109,7 +109,7 @@ impl fmt::Display for DstUnreachable {
             }
             DstUnreachable::HostPrecedViol => write!(f, "host precedence violation"),
             DstUnreachable::PrecedCutoff => write!(f, "precedence cutoff in effect"),
-            DstUnreachable::Unknown(id) => write!(f, "{}", id),
+            DstUnreachable::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -143,7 +143,7 @@ impl fmt::Display for TimeExceeded {
         match *self {
             TimeExceeded::TtlExpired => write!(f, "time-to-live exceeded in transit"),
             TimeExceeded::FragExpired => write!(f, "fragment reassembly time exceeded"),
-            TimeExceeded::Unknown(id) => write!(f, "{}", id),
+            TimeExceeded::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -556,9 +556,9 @@ impl<'a> Repr<'a> {
 impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self, &ChecksumCapabilities::default()) {
-            Ok(repr) => write!(f, "{}", repr),
+            Ok(repr) => write!(f, "{repr}"),
             Err(err) => {
-                write!(f, "ICMPv4 ({})", err)?;
+                write!(f, "ICMPv4 ({err})")?;
                 write!(f, " type={:?}", self.msg_type())?;
                 match self.msg_type() {
                     Message::DstUnreachable => {
@@ -600,10 +600,10 @@ impl<'a> fmt::Display for Repr<'a> {
                 data.len()
             ),
             Repr::DstUnreachable { reason, .. } => {
-                write!(f, "ICMPv4 destination unreachable ({})", reason)
+                write!(f, "ICMPv4 destination unreachable ({reason})")
             }
             Repr::TimeExceeded { reason, .. } => {
-                write!(f, "ICMPv4 time exceeded ({})", reason)
+                write!(f, "ICMPv4 time exceeded ({reason})")
             }
         }
     }
@@ -618,10 +618,10 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
         indent: &mut PrettyIndent,
     ) -> fmt::Result {
         let packet = match Packet::new_checked(buffer) {
-            Err(err) => return write!(f, "{}({})", indent, err),
+            Err(err) => return write!(f, "{indent}({err})"),
             Ok(packet) => packet,
         };
-        write!(f, "{}{}", indent, packet)?;
+        write!(f, "{indent}{packet}")?;
 
         match packet.msg_type() {
             Message::DstUnreachable | Message::TimeExceeded => {

+ 4 - 4
src/wire/icmpv6.rs

@@ -94,7 +94,7 @@ impl fmt::Display for Message {
             Message::Redirect => write!(f, "redirect"),
             Message::MldQuery => write!(f, "multicast listener query"),
             Message::MldReport => write!(f, "multicast listener report"),
-            Message::Unknown(id) => write!(f, "{}", id),
+            Message::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -134,7 +134,7 @@ impl fmt::Display for DstUnreachable {
                 write!(f, "source address failed ingress/egress policy")
             }
             DstUnreachable::RejectRoute => write!(f, "reject route to destination"),
-            DstUnreachable::Unknown(id) => write!(f, "{}", id),
+            DstUnreachable::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -157,7 +157,7 @@ impl fmt::Display for ParamProblem {
             ParamProblem::ErroneousHdrField => write!(f, "erroneous header field."),
             ParamProblem::UnrecognizedNxtHdr => write!(f, "unrecognized next header type."),
             ParamProblem::UnrecognizedOption => write!(f, "unrecognized IPv6 option."),
-            ParamProblem::Unknown(id) => write!(f, "{}", id),
+            ParamProblem::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -177,7 +177,7 @@ impl fmt::Display for TimeExceeded {
         match *self {
             TimeExceeded::HopLimitExceeded => write!(f, "hop limit exceeded in transit"),
             TimeExceeded::FragReassemExceeded => write!(f, "fragment reassembly time exceeded"),
-            TimeExceeded::Unknown(id) => write!(f, "{}", id),
+            TimeExceeded::Unknown(id) => write!(f, "{id}"),
         }
     }
 }

+ 2 - 2
src/wire/ieee802154.rs

@@ -28,7 +28,7 @@ impl fmt::Display for FrameType {
             FrameType::Multipurpose => write!(f, "Multipurpose"),
             FrameType::FragmentOrFrak => write!(f, "FragmentOrFrak"),
             FrameType::Extended => write!(f, "Extended"),
-            FrameType::Unknown(id) => write!(f, "0b{:04b}", id),
+            FrameType::Unknown(id) => write!(f, "0b{id:04b}"),
         }
     }
 }
@@ -59,7 +59,7 @@ impl fmt::Display for AddressingMode {
             AddressingMode::Absent => write!(f, "Absent"),
             AddressingMode::Short => write!(f, "Short"),
             AddressingMode::Extended => write!(f, "Extended"),
-            AddressingMode::Unknown(id) => write!(f, "0b{:04b}", id),
+            AddressingMode::Unknown(id) => write!(f, "0b{id:04b}"),
         }
     }
 }

+ 8 - 10
src/wire/igmp.rs

@@ -44,7 +44,7 @@ impl fmt::Display for Message {
             Message::MembershipReportV2 => write!(f, "version 2 membership report"),
             Message::LeaveGroup => write!(f, "leave group"),
             Message::MembershipReportV1 => write!(f, "version 1 membership report"),
-            Message::Unknown(id) => write!(f, "{}", id),
+            Message::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -324,8 +324,8 @@ const fn duration_to_max_resp_code(duration: Duration) -> u8 {
 impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self) {
-            Ok(repr) => write!(f, "{}", repr),
-            Err(err) => write!(f, "IGMP ({})", err),
+            Ok(repr) => write!(f, "{repr}"),
+            Err(err) => write!(f, "IGMP ({err})"),
         }
     }
 }
@@ -339,19 +339,17 @@ impl fmt::Display for Repr {
                 version,
             } => write!(
                 f,
-                "IGMP membership query max_resp_time={} group_addr={} version={:?}",
-                max_resp_time, group_addr, version
+                "IGMP membership query max_resp_time={max_resp_time} group_addr={group_addr} version={version:?}"
             ),
             Repr::MembershipReport {
                 group_addr,
                 version,
             } => write!(
                 f,
-                "IGMP membership report group_addr={} version={:?}",
-                group_addr, version
+                "IGMP membership report group_addr={group_addr} version={version:?}"
             ),
             Repr::LeaveGroup { group_addr } => {
-                write!(f, "IGMP leave group group_addr={})", group_addr)
+                write!(f, "IGMP leave group group_addr={group_addr})")
             }
         }
     }
@@ -366,8 +364,8 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
         indent: &mut PrettyIndent,
     ) -> fmt::Result {
         match Packet::new_checked(buffer) {
-            Err(err) => writeln!(f, "{}({})", indent, err),
-            Ok(packet) => writeln!(f, "{}{}", indent, packet),
+            Err(err) => writeln!(f, "{indent}({err})"),
+            Ok(packet) => writeln!(f, "{indent}{packet}"),
         }
     }
 }

+ 14 - 14
src/wire/ip.rs

@@ -74,7 +74,7 @@ impl fmt::Display for Protocol {
             Protocol::Icmpv6 => write!(f, "ICMPv6"),
             Protocol::Ipv6NoNxt => write!(f, "IPv6-NoNxt"),
             Protocol::Ipv6Opts => write!(f, "IPv6-Opts"),
-            Protocol::Unknown(id) => write!(f, "0x{:02x}", id),
+            Protocol::Unknown(id) => write!(f, "0x{id:02x}"),
         }
     }
 }
@@ -245,9 +245,9 @@ impl fmt::Display for Address {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             #[cfg(feature = "proto-ipv4")]
-            Address::Ipv4(addr) => write!(f, "{}", addr),
+            Address::Ipv4(addr) => write!(f, "{addr}"),
             #[cfg(feature = "proto-ipv6")]
-            Address::Ipv6(addr) => write!(f, "{}", addr),
+            Address::Ipv6(addr) => write!(f, "{addr}"),
         }
     }
 }
@@ -313,9 +313,9 @@ impl Cidr {
     pub fn contains_addr(&self, addr: &Address) -> bool {
         match (self, addr) {
             #[cfg(feature = "proto-ipv4")]
-            (&Cidr::Ipv4(ref cidr), &Address::Ipv4(ref addr)) => cidr.contains_addr(addr),
+            (Cidr::Ipv4(cidr), Address::Ipv4(addr)) => cidr.contains_addr(addr),
             #[cfg(feature = "proto-ipv6")]
-            (&Cidr::Ipv6(ref cidr), &Address::Ipv6(ref addr)) => cidr.contains_addr(addr),
+            (Cidr::Ipv6(cidr), Address::Ipv6(addr)) => cidr.contains_addr(addr),
             #[allow(unreachable_patterns)]
             _ => false,
         }
@@ -326,9 +326,9 @@ impl Cidr {
     pub fn contains_subnet(&self, subnet: &Cidr) -> bool {
         match (self, subnet) {
             #[cfg(feature = "proto-ipv4")]
-            (&Cidr::Ipv4(ref cidr), &Cidr::Ipv4(ref other)) => cidr.contains_subnet(other),
+            (Cidr::Ipv4(cidr), Cidr::Ipv4(other)) => cidr.contains_subnet(other),
             #[cfg(feature = "proto-ipv6")]
-            (&Cidr::Ipv6(ref cidr), &Cidr::Ipv6(ref other)) => cidr.contains_subnet(other),
+            (Cidr::Ipv6(cidr), Cidr::Ipv6(other)) => cidr.contains_subnet(other),
             #[allow(unreachable_patterns)]
             _ => false,
         }
@@ -353,9 +353,9 @@ impl fmt::Display for Cidr {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             #[cfg(feature = "proto-ipv4")]
-            Cidr::Ipv4(cidr) => write!(f, "{}", cidr),
+            Cidr::Ipv4(cidr) => write!(f, "{cidr}"),
             #[cfg(feature = "proto-ipv6")]
-            Cidr::Ipv6(cidr) => write!(f, "{}", cidr),
+            Cidr::Ipv6(cidr) => write!(f, "{cidr}"),
         }
     }
 }
@@ -826,7 +826,7 @@ pub fn pretty_print_ip_payload<T: Into<Repr>>(
         Protocol::Udp => {
             indent.increase(f)?;
             match UdpPacket::<&[u8]>::new_checked(payload) {
-                Err(err) => write!(f, "{}({})", indent, err),
+                Err(err) => write!(f, "{indent}({err})"),
                 Ok(udp_packet) => {
                     match UdpRepr::parse(
                         &udp_packet,
@@ -834,7 +834,7 @@ pub fn pretty_print_ip_payload<T: Into<Repr>>(
                         &repr.dst_addr(),
                         &checksum_caps,
                     ) {
-                        Err(err) => write!(f, "{}{} ({})", indent, udp_packet, err),
+                        Err(err) => write!(f, "{indent}{udp_packet} ({err})"),
                         Ok(udp_repr) => {
                             write!(
                                 f,
@@ -854,7 +854,7 @@ pub fn pretty_print_ip_payload<T: Into<Repr>>(
         Protocol::Tcp => {
             indent.increase(f)?;
             match TcpPacket::<&[u8]>::new_checked(payload) {
-                Err(err) => write!(f, "{}({})", indent, err),
+                Err(err) => write!(f, "{indent}({err})"),
                 Ok(tcp_packet) => {
                     match TcpRepr::parse(
                         &tcp_packet,
@@ -862,9 +862,9 @@ pub fn pretty_print_ip_payload<T: Into<Repr>>(
                         &repr.dst_addr(),
                         &checksum_caps,
                     ) {
-                        Err(err) => write!(f, "{}{} ({})", indent, tcp_packet, err),
+                        Err(err) => write!(f, "{indent}{tcp_packet} ({err})"),
                         Ok(tcp_repr) => {
-                            write!(f, "{}{}", indent, tcp_repr)?;
+                            write!(f, "{indent}{tcp_repr}")?;
                             let valid =
                                 tcp_packet.verify_checksum(&repr.src_addr(), &repr.dst_addr());
                             format_checksum(f, valid)

+ 4 - 4
src/wire/ipv4.rs

@@ -702,9 +702,9 @@ impl Repr {
 impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self, &ChecksumCapabilities::ignored()) {
-            Ok(repr) => write!(f, "{}", repr),
+            Ok(repr) => write!(f, "{repr}"),
             Err(err) => {
-                write!(f, "IPv4 ({})", err)?;
+                write!(f, "IPv4 ({err})")?;
                 write!(
                     f,
                     " src={} dst={} proto={} hop_limit={}",
@@ -767,7 +767,7 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
         let checksum_caps = ChecksumCapabilities::ignored();
 
         let (ip_repr, payload) = match Packet::new_checked(buffer) {
-            Err(err) => return write!(f, "{}({})", indent, err),
+            Err(err) => return write!(f, "{indent}({err})"),
             Ok(ip_packet) => match Repr::parse(&ip_packet, &checksum_caps) {
                 Err(_) => return Ok(()),
                 Ok(ip_repr) => {
@@ -781,7 +781,7 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
                         )?;
                         return Ok(());
                     } else {
-                        write!(f, "{}{}", indent, ip_repr)?;
+                        write!(f, "{indent}{ip_repr}")?;
                         format_checksum(f, ip_packet.verify_checksum())?;
                         (ip_repr, ip_packet.payload())
                     }

+ 7 - 7
src/wire/ipv6.rs

@@ -286,17 +286,17 @@ impl fmt::Display for Address {
                 // When the state is Head or Tail write a u16 in hexadecimal
                 // without the leading colon if the value is not 0.
                 (_, &State::Head) => {
-                    write!(f, "{:x}", word)?;
+                    write!(f, "{word:x}")?;
                     State::HeadBody
                 }
                 (_, &State::Tail) => {
-                    write!(f, "{:x}", word)?;
+                    write!(f, "{word:x}")?;
                     State::TailBody
                 }
                 // Write the u16 with a leading colon when parsing a value
                 // that isn't the first in a section
                 (_, &State::HeadBody) | (_, &State::TailBody) => {
-                    write!(f, ":{:x}", word)?;
+                    write!(f, ":{word:x}")?;
                     state
                 }
             }
@@ -638,9 +638,9 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
 impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self) {
-            Ok(repr) => write!(f, "{}", repr),
+            Ok(repr) => write!(f, "{repr}"),
             Err(err) => {
-                write!(f, "IPv6 ({})", err)?;
+                write!(f, "IPv6 ({err})")?;
                 Ok(())
             }
         }
@@ -728,11 +728,11 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
         indent: &mut PrettyIndent,
     ) -> fmt::Result {
         let (ip_repr, payload) = match Packet::new_checked(buffer) {
-            Err(err) => return write!(f, "{}({})", indent, err),
+            Err(err) => return write!(f, "{indent}({err})"),
             Ok(ip_packet) => match Repr::parse(&ip_packet) {
                 Err(_) => return Ok(()),
                 Ok(ip_repr) => {
-                    write!(f, "{}{}", indent, ip_repr)?;
+                    write!(f, "{indent}{ip_repr}")?;
                     (ip_repr, ip_packet.payload())
                 }
             },

+ 2 - 2
src/wire/ipv6fragment.rs

@@ -148,9 +148,9 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Header<T> {
 impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Header<&'a T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self) {
-            Ok(repr) => write!(f, "{}", repr),
+            Ok(repr) => write!(f, "{repr}"),
             Err(err) => {
-                write!(f, "IPv6 Fragment ({})", err)?;
+                write!(f, "IPv6 Fragment ({err})")?;
                 Ok(())
             }
         }

+ 2 - 2
src/wire/ipv6hopbyhop.rs

@@ -147,9 +147,9 @@ impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Header<&'a mut T> {
 impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Header<&'a T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self) {
-            Ok(repr) => write!(f, "{}", repr),
+            Ok(repr) => write!(f, "{repr}"),
             Err(err) => {
-                write!(f, "IPv6 Hop-by-Hop Options ({})", err)?;
+                write!(f, "IPv6 Hop-by-Hop Options ({err})")?;
                 Ok(())
             }
         }

+ 5 - 5
src/wire/ipv6option.rs

@@ -16,7 +16,7 @@ impl fmt::Display for Type {
         match *self {
             Type::Pad1 => write!(f, "Pad1"),
             Type::PadN => write!(f, "PadN"),
-            Type::Unknown(id) => write!(f, "{}", id),
+            Type::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -44,7 +44,7 @@ impl fmt::Display for FailureType {
             FailureType::Discard => write!(f, "discard"),
             FailureType::DiscardSendAll => write!(f, "discard and send error"),
             FailureType::DiscardSendUnicast => write!(f, "discard and send error if unicast"),
-            FailureType::Unknown(id) => write!(f, "Unknown({})", id),
+            FailureType::Unknown(id) => write!(f, "Unknown({id})"),
         }
     }
 }
@@ -204,9 +204,9 @@ impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Ipv6Option<&'a mut T> {
 impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Ipv6Option<&'a T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self) {
-            Ok(repr) => write!(f, "{}", repr),
+            Ok(repr) => write!(f, "{repr}"),
             Err(err) => {
-                write!(f, "IPv6 Extension Option ({})", err)?;
+                write!(f, "IPv6 Extension Option ({err})")?;
                 Ok(())
             }
         }
@@ -344,7 +344,7 @@ impl<'a> fmt::Display for Repr<'a> {
         match *self {
             Repr::Pad1 => write!(f, "{} ", Type::Pad1),
             Repr::PadN(len) => write!(f, "{} length={} ", Type::PadN, len),
-            Repr::Unknown { type_, length, .. } => write!(f, "{} length={} ", type_, length),
+            Repr::Unknown { type_, length, .. } => write!(f, "{type_} length={length} "),
         }
     }
 }

+ 3 - 3
src/wire/ipv6routing.rs

@@ -44,7 +44,7 @@ impl fmt::Display for Type {
             Type::Experiment1 => write!(f, "Experiment1"),
             Type::Experiment2 => write!(f, "Experiment2"),
             Type::Reserved => write!(f, "Reserved"),
-            Type::Unknown(id) => write!(f, "{}", id),
+            Type::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -385,9 +385,9 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Header<T> {
 impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Header<&'a T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self) {
-            Ok(repr) => write!(f, "{}", repr),
+            Ok(repr) => write!(f, "{repr}"),
             Err(err) => {
-                write!(f, "IPv6 Routing ({})", err)?;
+                write!(f, "IPv6 Routing ({err})")?;
                 Ok(())
             }
         }

+ 3 - 3
src/wire/mod.rs

@@ -319,9 +319,9 @@ impl core::fmt::Display for HardwareAddress {
     fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
         match self {
             #[cfg(feature = "medium-ethernet")]
-            HardwareAddress::Ethernet(addr) => write!(f, "{}", addr),
+            HardwareAddress::Ethernet(addr) => write!(f, "{addr}"),
             #[cfg(feature = "medium-ieee802154")]
-            HardwareAddress::Ieee802154(addr) => write!(f, "{}", addr),
+            HardwareAddress::Ieee802154(addr) => write!(f, "{addr}"),
         }
     }
 }
@@ -413,7 +413,7 @@ impl core::fmt::Display for RawHardwareAddress {
             if i != 0 {
                 write!(f, ":")?;
             }
-            write!(f, "{:02x}", b)?;
+            write!(f, "{b:02x}")?;
         }
         Ok(())
     }

+ 11 - 11
src/wire/ndiscoption.rs

@@ -32,7 +32,7 @@ impl fmt::Display for Type {
             Type::PrefixInformation => write!(f, "prefix information"),
             Type::RedirectedHeader => write!(f, "redirected header"),
             Type::Mtu => write!(f, "mtu"),
-            Type::Unknown(id) => write!(f, "{}", id),
+            Type::Unknown(id) => write!(f, "{id}"),
         }
     }
 }
@@ -383,9 +383,9 @@ impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> NdiscOption<&'a mut T> {
 impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for NdiscOption<&'a T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match Repr::parse(self) {
-            Ok(repr) => write!(f, "{}", repr),
+            Ok(repr) => write!(f, "{repr}"),
             Err(err) => {
-                write!(f, "NDISC Option ({})", err)?;
+                write!(f, "NDISC Option ({err})")?;
                 Ok(())
             }
         }
@@ -583,26 +583,26 @@ impl<'a> fmt::Display for Repr<'a> {
         write!(f, "NDISC Option: ")?;
         match *self {
             Repr::SourceLinkLayerAddr(addr) => {
-                write!(f, "SourceLinkLayer addr={}", addr)
+                write!(f, "SourceLinkLayer addr={addr}")
             }
             Repr::TargetLinkLayerAddr(addr) => {
-                write!(f, "TargetLinkLayer addr={}", addr)
+                write!(f, "TargetLinkLayer addr={addr}")
             }
             Repr::PrefixInformation(PrefixInformation {
                 prefix, prefix_len, ..
             }) => {
-                write!(f, "PrefixInformation prefix={}/{}", prefix, prefix_len)
+                write!(f, "PrefixInformation prefix={prefix}/{prefix_len}")
             }
             Repr::RedirectedHeader(RedirectedHeader { header, .. }) => {
-                write!(f, "RedirectedHeader header={}", header)
+                write!(f, "RedirectedHeader header={header}")
             }
             Repr::Mtu(mtu) => {
-                write!(f, "MTU mtu={}", mtu)
+                write!(f, "MTU mtu={mtu}")
             }
             Repr::Unknown {
                 type_: id, length, ..
             } => {
-                write!(f, "Unknown({}) length={}", id, length)
+                write!(f, "Unknown({id}) length={length}")
             }
         }
     }
@@ -617,11 +617,11 @@ impl<T: AsRef<[u8]>> PrettyPrint for NdiscOption<T> {
         indent: &mut PrettyIndent,
     ) -> fmt::Result {
         match NdiscOption::new_checked(buffer) {
-            Err(err) => write!(f, "{}({})", indent, err),
+            Err(err) => write!(f, "{indent}({err})"),
             Ok(ndisc) => match Repr::parse(&ndisc) {
                 Err(_) => Ok(()),
                 Ok(repr) => {
-                    write!(f, "{}{}", indent, repr)
+                    write!(f, "{indent}{repr}")
                 }
             },
         }

+ 9 - 9
src/wire/tcp.rs

@@ -1024,16 +1024,16 @@ impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
         while !options.is_empty() {
             let (next_options, option) = match TcpOption::parse(options) {
                 Ok(res) => res,
-                Err(err) => return write!(f, " ({})", err),
+                Err(err) => return write!(f, " ({err})"),
             };
             match option {
                 TcpOption::EndOfList => break,
                 TcpOption::NoOperation => (),
-                TcpOption::MaxSegmentSize(value) => write!(f, " mss={}", value)?,
-                TcpOption::WindowScale(value) => write!(f, " ws={}", value)?,
+                TcpOption::MaxSegmentSize(value) => write!(f, " mss={value}")?,
+                TcpOption::WindowScale(value) => write!(f, " ws={value}")?,
                 TcpOption::SackPermitted => write!(f, " sACK")?,
-                TcpOption::SackRange(slice) => write!(f, " sACKr{:?}", slice)?, // debug print conveniently includes the []s
-                TcpOption::Unknown { kind, .. } => write!(f, " opt({})", kind)?,
+                TcpOption::SackRange(slice) => write!(f, " sACKr{slice:?}")?, // debug print conveniently includes the []s
+                TcpOption::Unknown { kind, .. } => write!(f, " opt({kind})")?,
             }
             options = next_options;
         }
@@ -1053,12 +1053,12 @@ impl<'a> fmt::Display for Repr<'a> {
         }
         write!(f, " seq={}", self.seq_number)?;
         if let Some(ack_number) = self.ack_number {
-            write!(f, " ack={}", ack_number)?;
+            write!(f, " ack={ack_number}")?;
         }
         write!(f, " win={}", self.window_len)?;
         write!(f, " len={}", self.payload.len())?;
         if let Some(max_seg_size) = self.max_seg_size {
-            write!(f, " mss={}", max_seg_size)?;
+            write!(f, " mss={max_seg_size}")?;
         }
         Ok(())
     }
@@ -1073,8 +1073,8 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
         indent: &mut PrettyIndent,
     ) -> fmt::Result {
         match Packet::new_checked(buffer) {
-            Err(err) => write!(f, "{}({})", indent, err),
-            Ok(packet) => write!(f, "{}{}", indent, packet),
+            Err(err) => write!(f, "{indent}({err})"),
+            Ok(packet) => write!(f, "{indent}{packet}"),
         }
     }
 }

+ 2 - 2
src/wire/udp.rs

@@ -305,8 +305,8 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
         indent: &mut PrettyIndent,
     ) -> fmt::Result {
         match Packet::new_checked(buffer) {
-            Err(err) => write!(f, "{}({})", indent, err),
-            Ok(packet) => write!(f, "{}{}", indent, packet),
+            Err(err) => write!(f, "{indent}({err})"),
+            Ok(packet) => write!(f, "{indent}{packet}"),
         }
     }
 }