Skip to content

Commit

Permalink
Elide many explicit lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
ususdei committed Jan 14, 2025
1 parent 9f409ff commit 13605ac
Show file tree
Hide file tree
Showing 27 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/iface/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/iface/socket_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct SocketStorage<'a> {
inner: Option<Item<'a>>,
}

impl<'a> SocketStorage<'a> {
impl SocketStorage<'_> {
pub const EMPTY: Self = Self { inner: None };
}

Expand Down
4 changes: 2 additions & 2 deletions src/phy/fault_injector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub struct RxToken<'a> {
meta: PacketMeta,
}

impl<'a> phy::RxToken for RxToken<'a> {
impl phy::RxToken for RxToken<'_> {
fn consume<R, F>(self, f: F) -> R
where
F: FnOnce(&[u8]) -> R,
Expand All @@ -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<Tx: phy::TxToken> phy::TxToken for TxToken<'_, Tx> {
fn consume<R, F>(mut self, len: usize, f: F) -> R
where
F: FnOnce(&mut [u8]) -> R,
Expand Down
4 changes: 2 additions & 2 deletions src/phy/fuzz_injector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rx: phy::RxToken, FRx: Fuzzer> phy::RxToken for RxToken<'_, Rx, FRx> {
fn consume<R, F>(self, f: F) -> R
where
F: FnOnce(&[u8]) -> R,
Expand All @@ -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<Tx: phy::TxToken, FTx: Fuzzer> phy::TxToken for TxToken<'_, Tx, FTx> {
fn consume<R, F>(self, len: usize, f: F) -> R
where
F: FnOnce(&mut [u8]) -> R,
Expand Down
2 changes: 1 addition & 1 deletion src/phy/loopback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub struct TxToken<'a> {
queue: &'a mut VecDeque<Vec<u8>>,
}

impl<'a> phy::TxToken for TxToken<'a> {
impl phy::TxToken for TxToken<'_> {
fn consume<R, F>(self, len: usize, f: F) -> R
where
F: FnOnce(&mut [u8]) -> R,
Expand Down
4 changes: 2 additions & 2 deletions src/phy/pcap_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rx: phy::RxToken, S: PcapSink> phy::RxToken for RxToken<'_, Rx, S> {
fn consume<R, F: FnOnce(&[u8]) -> R>(self, f: F) -> R {
self.token.consume(|buffer| {
match self.mode {
Expand All @@ -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<Tx: phy::TxToken, S: PcapSink> phy::TxToken for TxToken<'_, Tx, S> {
fn consume<R, F>(self, len: usize, f: F) -> R
where
F: FnOnce(&mut [u8]) -> R,
Expand Down
2 changes: 1 addition & 1 deletion src/phy/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/storage/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)> {
Expand Down
2 changes: 1 addition & 1 deletion src/wire/dhcpv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
}
}

impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&'a mut T> {
impl<T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&mut T> {
/// Return a pointer to the options.
#[inline]
pub fn options_mut(&mut self) -> DhcpOptionWriter<'_> {
Expand Down
2 changes: 1 addition & 1 deletion src/wire/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/wire/icmpv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
}
}

impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&'a mut T> {
impl<T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&mut T> {
/// Return a mutable pointer to the type-specific data.
#[inline]
pub fn data_mut(&mut self) -> &mut [u8] {
Expand Down Expand Up @@ -555,7 +555,7 @@ impl<'a> Repr<'a> {
}
}

impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
impl<T: AsRef<[u8]> + ?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}"),
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/wire/igmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match Repr::parse(self) {
Ok(repr) => write!(f, "{repr}"),
Expand Down
2 changes: 1 addition & 1 deletion src/wire/ipv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ impl Repr {
}
}

impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
impl<T: AsRef<[u8]> + ?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}"),
Expand Down
2 changes: 1 addition & 1 deletion src/wire/ipv6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
}
}

impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
impl<T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match Repr::parse(self) {
Ok(repr) => write!(f, "{repr}"),
Expand Down
2 changes: 1 addition & 1 deletion src/wire/ipv6ext_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Header<T> {
}
}

impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Header<&'a mut T> {
impl<T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Header<&mut T> {
/// Return a mutable pointer to the payload data.
#[inline]
pub fn payload_mut(&mut self) -> &mut [u8] {
Expand Down
2 changes: 1 addition & 1 deletion src/wire/ipv6fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Header<T> {
}
}

impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Header<&'a T> {
impl<T: AsRef<[u8]> + ?Sized> fmt::Display for Header<&T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match Repr::parse(self) {
Ok(repr) => write!(f, "{repr}"),
Expand Down
2 changes: 1 addition & 1 deletion src/wire/ipv6hbh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: AsRef<[u8]> + 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()
Expand Down
6 changes: 3 additions & 3 deletions src/wire/ipv6option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Ipv6Option<T> {
}
}

impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Ipv6Option<&'a mut T> {
impl<T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Ipv6Option<&mut T> {
/// Return a mutable pointer to the option data.
///
/// # Panics
Expand All @@ -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<T: AsRef<[u8]> + ?Sized> fmt::Display for Ipv6Option<&T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match Repr::parse(self) {
Ok(repr) => write!(f, "{repr}"),
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/wire/ipv6routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Header<T> {
}
}

impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Header<&'a T> {
impl<T: AsRef<[u8]> + ?Sized> fmt::Display for Header<&T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match Repr::parse(self) {
Ok(repr) => write!(f, "{repr}"),
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/wire/ndiscoption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> NdiscOption<T> {
}
}

impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> NdiscOption<&'a mut T> {
impl<T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> NdiscOption<&mut T> {
/// Return a mutable pointer to the option data.
#[inline]
pub fn data_mut(&mut self) -> &mut [u8] {
Expand All @@ -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<T: AsRef<[u8]> + ?Sized> fmt::Display for NdiscOption<&T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match Repr::parse(self) {
Ok(repr) => write!(f, "{repr}"),
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/wire/pretty_print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<'a, T: PrettyPrint + AsRef<[u8]>> PrettyPrinter<'a, T> {
}
}

impl<'a, T: PrettyPrint> fmt::Display for PrettyPrinter<'a, T> {
impl<T: PrettyPrint> 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))
}
Expand Down
2 changes: 1 addition & 1 deletion src/wire/sixlowpan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LlAddress>,
Expand Down
4 changes: 2 additions & 2 deletions src/wire/sixlowpan/nhc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,10 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> UdpNhcPacket<T> {
#[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<T: AsRef<[u8]> + ?Sized>(
packet: &UdpNhcPacket<&'a T>,
packet: &UdpNhcPacket<&T>,
src_addr: &ipv6::Address,
dst_addr: &ipv6::Address,
checksum_caps: &ChecksumCapabilities,
Expand Down
4 changes: 2 additions & 2 deletions src/wire/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ impl<'a> Repr<'a> {
}
}

impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
impl<T: AsRef<[u8]> + ?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())?;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/wire/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl Repr {
}
}

impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
impl<T: AsRef<[u8]> + ?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!(
Expand Down

0 comments on commit 13605ac

Please sign in to comment.