From 13605ac43ba2cc20516d1672c743a145479fd396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Bl=C3=B6chl?= Date: Tue, 14 Jan 2025 21:03:53 +0100 Subject: [PATCH] Elide many explicit lifetimes --- src/iface/packet.rs | 2 +- src/iface/socket_set.rs | 2 +- src/phy/fault_injector.rs | 4 ++-- src/phy/fuzz_injector.rs | 4 ++-- src/phy/loopback.rs | 2 +- src/phy/pcap_writer.rs | 4 ++-- src/phy/tracer.rs | 2 +- src/socket/mod.rs | 2 +- src/socket/tcp.rs | 2 +- src/storage/assembler.rs | 2 +- src/wire/dhcpv4.rs | 2 +- src/wire/dns.rs | 2 +- src/wire/icmpv4.rs | 6 +++--- src/wire/igmp.rs | 2 +- src/wire/ipv4.rs | 2 +- src/wire/ipv6.rs | 2 +- src/wire/ipv6ext_header.rs | 2 +- src/wire/ipv6fragment.rs | 2 +- src/wire/ipv6hbh.rs | 2 +- src/wire/ipv6option.rs | 6 +++--- src/wire/ipv6routing.rs | 4 ++-- src/wire/ndiscoption.rs | 6 +++--- src/wire/pretty_print.rs | 2 +- src/wire/sixlowpan/mod.rs | 2 +- src/wire/sixlowpan/nhc.rs | 4 ++-- src/wire/tcp.rs | 4 ++-- src/wire/udp.rs | 2 +- 27 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/iface/packet.rs b/src/iface/packet.rs index 1ccc6766b..0a5d9571a 100644 --- a/src/iface/packet.rs +++ b/src/iface/packet.rs @@ -223,7 +223,7 @@ pub(crate) enum IpPayload<'p> { Dhcpv4(UdpRepr, DhcpRepr<'p>), } -impl<'p> IpPayload<'p> { +impl IpPayload<'_> { #[cfg(feature = "proto-sixlowpan")] pub(crate) fn as_sixlowpan_next_header(&self) -> SixlowpanNextHeader { match self { diff --git a/src/iface/socket_set.rs b/src/iface/socket_set.rs index be55fef5d..b70332deb 100644 --- a/src/iface/socket_set.rs +++ b/src/iface/socket_set.rs @@ -13,7 +13,7 @@ pub struct SocketStorage<'a> { inner: Option>, } -impl<'a> SocketStorage<'a> { +impl SocketStorage<'_> { pub const EMPTY: Self = Self { inner: None }; } diff --git a/src/phy/fault_injector.rs b/src/phy/fault_injector.rs index 1f30db549..df7a46cef 100644 --- a/src/phy/fault_injector.rs +++ b/src/phy/fault_injector.rs @@ -273,7 +273,7 @@ pub struct RxToken<'a> { meta: PacketMeta, } -impl<'a> phy::RxToken for RxToken<'a> { +impl phy::RxToken for RxToken<'_> { fn consume(self, f: F) -> R where F: FnOnce(&[u8]) -> R, @@ -295,7 +295,7 @@ pub struct TxToken<'a, Tx: phy::TxToken> { timestamp: Instant, } -impl<'a, Tx: phy::TxToken> phy::TxToken for TxToken<'a, Tx> { +impl phy::TxToken for TxToken<'_, Tx> { fn consume(mut self, len: usize, f: F) -> R where F: FnOnce(&mut [u8]) -> R, diff --git a/src/phy/fuzz_injector.rs b/src/phy/fuzz_injector.rs index 5598488a0..4c97823e1 100644 --- a/src/phy/fuzz_injector.rs +++ b/src/phy/fuzz_injector.rs @@ -92,7 +92,7 @@ pub struct RxToken<'a, Rx: phy::RxToken, F: Fuzzer + 'a> { token: Rx, } -impl<'a, Rx: phy::RxToken, FRx: Fuzzer> phy::RxToken for RxToken<'a, Rx, FRx> { +impl phy::RxToken for RxToken<'_, Rx, FRx> { fn consume(self, f: F) -> R where F: FnOnce(&[u8]) -> R, @@ -115,7 +115,7 @@ pub struct TxToken<'a, Tx: phy::TxToken, F: Fuzzer + 'a> { token: Tx, } -impl<'a, Tx: phy::TxToken, FTx: Fuzzer> phy::TxToken for TxToken<'a, Tx, FTx> { +impl phy::TxToken for TxToken<'_, Tx, FTx> { fn consume(self, len: usize, f: F) -> R where F: FnOnce(&mut [u8]) -> R, diff --git a/src/phy/loopback.rs b/src/phy/loopback.rs index fd3aea7d1..896d8ff47 100644 --- a/src/phy/loopback.rs +++ b/src/phy/loopback.rs @@ -76,7 +76,7 @@ pub struct TxToken<'a> { queue: &'a mut VecDeque>, } -impl<'a> phy::TxToken for TxToken<'a> { +impl phy::TxToken for TxToken<'_> { fn consume(self, len: usize, f: F) -> R where F: FnOnce(&mut [u8]) -> R, diff --git a/src/phy/pcap_writer.rs b/src/phy/pcap_writer.rs index 2ce23ff3f..a5778ece3 100644 --- a/src/phy/pcap_writer.rs +++ b/src/phy/pcap_writer.rs @@ -220,7 +220,7 @@ pub struct RxToken<'a, Rx: phy::RxToken, S: PcapSink> { timestamp: Instant, } -impl<'a, Rx: phy::RxToken, S: PcapSink> phy::RxToken for RxToken<'a, Rx, S> { +impl phy::RxToken for RxToken<'_, Rx, S> { fn consume R>(self, f: F) -> R { self.token.consume(|buffer| { match self.mode { @@ -247,7 +247,7 @@ pub struct TxToken<'a, Tx: phy::TxToken, S: PcapSink> { timestamp: Instant, } -impl<'a, Tx: phy::TxToken, S: PcapSink> phy::TxToken for TxToken<'a, Tx, S> { +impl phy::TxToken for TxToken<'_, Tx, S> { fn consume(self, len: usize, f: F) -> R where F: FnOnce(&mut [u8]) -> R, diff --git a/src/phy/tracer.rs b/src/phy/tracer.rs index eb51fcc95..ccd4b6ab8 100644 --- a/src/phy/tracer.rs +++ b/src/phy/tracer.rs @@ -154,7 +154,7 @@ pub struct Packet<'a> { prefix: &'static str, } -impl<'a> fmt::Display for Packet<'a> { +impl fmt::Display for Packet<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut indent = PrettyIndent::new(self.prefix); match self.medium { diff --git a/src/socket/mod.rs b/src/socket/mod.rs index 7d48b4234..048a6a327 100644 --- a/src/socket/mod.rs +++ b/src/socket/mod.rs @@ -71,7 +71,7 @@ pub enum Socket<'a> { Dns(dns::Socket<'a>), } -impl<'a> Socket<'a> { +impl Socket<'_> { pub(crate) fn poll_at(&self, cx: &mut Context) -> PollAt { match self { #[cfg(feature = "socket-raw")] diff --git a/src/socket/tcp.rs b/src/socket/tcp.rs index 42f99175f..b65e489a8 100644 --- a/src/socket/tcp.rs +++ b/src/socket/tcp.rs @@ -2603,7 +2603,7 @@ impl<'a> Socket<'a> { } } -impl<'a> fmt::Write for Socket<'a> { +impl fmt::Write for Socket<'_> { fn write_str(&mut self, slice: &str) -> fmt::Result { let slice = slice.as_bytes(); if self.send_slice(slice) == Ok(slice.len()) { diff --git a/src/storage/assembler.rs b/src/storage/assembler.rs index 365a1e03a..143ffd16c 100644 --- a/src/storage/assembler.rs +++ b/src/storage/assembler.rs @@ -352,7 +352,7 @@ impl<'a> AssemblerIter<'a> { } } -impl<'a> Iterator for AssemblerIter<'a> { +impl Iterator for AssemblerIter<'_> { type Item = (usize, usize); fn next(&mut self) -> Option<(usize, usize)> { diff --git a/src/wire/dhcpv4.rs b/src/wire/dhcpv4.rs index 87ace13e4..5a35b8fc4 100644 --- a/src/wire/dhcpv4.rs +++ b/src/wire/dhcpv4.rs @@ -531,7 +531,7 @@ impl + AsMut<[u8]>> Packet { } } -impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&'a mut T> { +impl + AsMut<[u8]> + ?Sized> Packet<&mut T> { /// Return a pointer to the options. #[inline] pub fn options_mut(&mut self) -> DhcpOptionWriter<'_> { diff --git a/src/wire/dns.rs b/src/wire/dns.rs index 68f504f58..f251366ca 100644 --- a/src/wire/dns.rs +++ b/src/wire/dns.rs @@ -410,7 +410,7 @@ pub struct Repr<'a> { pub question: Question<'a>, } -impl<'a> Repr<'a> { +impl Repr<'_> { /// Return the length of a packet that will be emitted from this high-level representation. pub const fn buffer_len(&self) -> usize { field::HEADER_END + self.question.buffer_len() diff --git a/src/wire/icmpv4.rs b/src/wire/icmpv4.rs index 0ef752511..9d2f8fdf1 100644 --- a/src/wire/icmpv4.rs +++ b/src/wire/icmpv4.rs @@ -346,7 +346,7 @@ impl + AsMut<[u8]>> Packet { } } -impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&'a mut T> { +impl + AsMut<[u8]> + ?Sized> Packet<&mut T> { /// Return a mutable pointer to the type-specific data. #[inline] pub fn data_mut(&mut self) -> &mut [u8] { @@ -555,7 +555,7 @@ impl<'a> Repr<'a> { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> { +impl + ?Sized> fmt::Display for Packet<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match Repr::parse(self, &ChecksumCapabilities::default()) { Ok(repr) => write!(f, "{repr}"), @@ -576,7 +576,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> { } } -impl<'a> fmt::Display for Repr<'a> { +impl fmt::Display for Repr<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Repr::EchoRequest { diff --git a/src/wire/igmp.rs b/src/wire/igmp.rs index ba282bab4..ea9e1079b 100644 --- a/src/wire/igmp.rs +++ b/src/wire/igmp.rs @@ -323,7 +323,7 @@ const fn duration_to_max_resp_code(duration: Duration) -> u8 { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> { +impl + ?Sized> fmt::Display for Packet<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match Repr::parse(self) { Ok(repr) => write!(f, "{repr}"), diff --git a/src/wire/ipv4.rs b/src/wire/ipv4.rs index 7629a46ed..24d61bd66 100644 --- a/src/wire/ipv4.rs +++ b/src/wire/ipv4.rs @@ -622,7 +622,7 @@ impl Repr { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> { +impl + ?Sized> fmt::Display for Packet<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match Repr::parse(self, &ChecksumCapabilities::ignored()) { Ok(repr) => write!(f, "{repr}"), diff --git a/src/wire/ipv6.rs b/src/wire/ipv6.rs index 24904b60a..e9e544411 100644 --- a/src/wire/ipv6.rs +++ b/src/wire/ipv6.rs @@ -552,7 +552,7 @@ impl + AsMut<[u8]>> Packet { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> { +impl + ?Sized> fmt::Display for Packet<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match Repr::parse(self) { Ok(repr) => write!(f, "{repr}"), diff --git a/src/wire/ipv6ext_header.rs b/src/wire/ipv6ext_header.rs index ded4a1886..8ee111958 100644 --- a/src/wire/ipv6ext_header.rs +++ b/src/wire/ipv6ext_header.rs @@ -111,7 +111,7 @@ impl + AsMut<[u8]>> Header { } } -impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Header<&'a mut T> { +impl + AsMut<[u8]> + ?Sized> Header<&mut T> { /// Return a mutable pointer to the payload data. #[inline] pub fn payload_mut(&mut self) -> &mut [u8] { diff --git a/src/wire/ipv6fragment.rs b/src/wire/ipv6fragment.rs index ce28bc1b9..a83bab7a0 100644 --- a/src/wire/ipv6fragment.rs +++ b/src/wire/ipv6fragment.rs @@ -126,7 +126,7 @@ impl + AsMut<[u8]>> Header { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Header<&'a T> { +impl + ?Sized> fmt::Display for Header<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match Repr::parse(self) { Ok(repr) => write!(f, "{repr}"), diff --git a/src/wire/ipv6hbh.rs b/src/wire/ipv6hbh.rs index 8d6bb31da..eb8bfd46f 100644 --- a/src/wire/ipv6hbh.rs +++ b/src/wire/ipv6hbh.rs @@ -51,7 +51,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Header<&'a T> { } } -impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Header<&'a mut T> { +impl + AsMut<[u8]> + ?Sized> Header<&mut T> { /// Return a mutable pointer to the options of the IPv6 Hop-by-Hop header. pub fn options_mut(&mut self) -> &mut [u8] { self.buffer.as_mut() diff --git a/src/wire/ipv6option.rs b/src/wire/ipv6option.rs index ffa2a14de..ffb58d66c 100644 --- a/src/wire/ipv6option.rs +++ b/src/wire/ipv6option.rs @@ -240,7 +240,7 @@ impl + AsMut<[u8]>> Ipv6Option { } } -impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Ipv6Option<&'a mut T> { +impl + AsMut<[u8]> + ?Sized> Ipv6Option<&mut T> { /// Return a mutable pointer to the option data. /// /// # Panics @@ -253,7 +253,7 @@ impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Ipv6Option<&'a mut T> { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Ipv6Option<&'a T> { +impl + ?Sized> fmt::Display for Ipv6Option<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match Repr::parse(self) { Ok(repr) => write!(f, "{repr}"), @@ -425,7 +425,7 @@ impl<'a> Iterator for Ipv6OptionsIterator<'a> { } } -impl<'a> fmt::Display for Repr<'a> { +impl fmt::Display for Repr<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "IPv6 Option ")?; match *self { diff --git a/src/wire/ipv6routing.rs b/src/wire/ipv6routing.rs index 530eac6e9..f50b3e41e 100644 --- a/src/wire/ipv6routing.rs +++ b/src/wire/ipv6routing.rs @@ -332,7 +332,7 @@ impl + AsMut<[u8]>> Header { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Header<&'a T> { +impl + ?Sized> fmt::Display for Header<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match Repr::parse(self) { Ok(repr) => write!(f, "{repr}"), @@ -435,7 +435,7 @@ impl<'a> Repr<'a> { } } -impl<'a> fmt::Display for Repr<'a> { +impl fmt::Display for Repr<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Repr::Type2 { diff --git a/src/wire/ndiscoption.rs b/src/wire/ndiscoption.rs index 583d9b569..9cd7f8ab4 100644 --- a/src/wire/ndiscoption.rs +++ b/src/wire/ndiscoption.rs @@ -370,7 +370,7 @@ impl + AsMut<[u8]>> NdiscOption { } } -impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> NdiscOption<&'a mut T> { +impl + AsMut<[u8]> + ?Sized> NdiscOption<&mut T> { /// Return a mutable pointer to the option data. #[inline] pub fn data_mut(&mut self) -> &mut [u8] { @@ -380,7 +380,7 @@ impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> NdiscOption<&'a mut T> { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for NdiscOption<&'a T> { +impl + ?Sized> fmt::Display for NdiscOption<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match Repr::parse(self) { Ok(repr) => write!(f, "{repr}"), @@ -581,7 +581,7 @@ impl<'a> Repr<'a> { } } -impl<'a> fmt::Display for Repr<'a> { +impl fmt::Display for Repr<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "NDISC Option: ")?; match *self { diff --git a/src/wire/pretty_print.rs b/src/wire/pretty_print.rs index fe7d8b892..51987efec 100644 --- a/src/wire/pretty_print.rs +++ b/src/wire/pretty_print.rs @@ -119,7 +119,7 @@ impl<'a, T: PrettyPrint + AsRef<[u8]>> PrettyPrinter<'a, T> { } } -impl<'a, T: PrettyPrint> fmt::Display for PrettyPrinter<'a, T> { +impl fmt::Display for PrettyPrinter<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { T::pretty_print(&self.buffer, f, &mut PrettyIndent::new(self.prefix)) } diff --git a/src/wire/sixlowpan/mod.rs b/src/wire/sixlowpan/mod.rs index 59c13bfe2..9de73f3ae 100644 --- a/src/wire/sixlowpan/mod.rs +++ b/src/wire/sixlowpan/mod.rs @@ -62,7 +62,7 @@ pub enum AddressMode<'a> { const LINK_LOCAL_PREFIX: [u8; 2] = [0xfe, 0x80]; const EUI64_MIDDLE_VALUE: [u8; 2] = [0xff, 0xfe]; -impl<'a> UnresolvedAddress<'a> { +impl UnresolvedAddress<'_> { pub fn resolve( self, ll_address: Option, diff --git a/src/wire/sixlowpan/nhc.rs b/src/wire/sixlowpan/nhc.rs index d558d1d5f..d81371924 100644 --- a/src/wire/sixlowpan/nhc.rs +++ b/src/wire/sixlowpan/nhc.rs @@ -686,10 +686,10 @@ impl + AsMut<[u8]>> UdpNhcPacket { #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct UdpNhcRepr(pub UdpRepr); -impl<'a> UdpNhcRepr { +impl UdpNhcRepr { /// Parse a 6LoWPAN NHC UDP packet and return a high-level representation. pub fn parse + ?Sized>( - packet: &UdpNhcPacket<&'a T>, + packet: &UdpNhcPacket<&T>, src_addr: &ipv6::Address, dst_addr: &ipv6::Address, checksum_caps: &ChecksumCapabilities, diff --git a/src/wire/tcp.rs b/src/wire/tcp.rs index e064182d9..f70b17b9e 100644 --- a/src/wire/tcp.rs +++ b/src/wire/tcp.rs @@ -1065,7 +1065,7 @@ impl<'a> Repr<'a> { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> { +impl + ?Sized> fmt::Display for Packet<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Cannot use Repr::parse because we don't have the IP addresses. write!(f, "TCP src={} dst={}", self.src_port(), self.dst_port())?; @@ -1124,7 +1124,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> { } } -impl<'a> fmt::Display for Repr<'a> { +impl fmt::Display for Repr<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TCP src={} dst={}", self.src_port, self.dst_port)?; match self.control { diff --git a/src/wire/udp.rs b/src/wire/udp.rs index 9d341e0ee..1cd901f03 100644 --- a/src/wire/udp.rs +++ b/src/wire/udp.rs @@ -292,7 +292,7 @@ impl Repr { } } -impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> { +impl + ?Sized> fmt::Display for Packet<&T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Cannot use Repr::parse because we don't have the IP addresses. write!(