Skip to content

Commit 4b7103c

Browse files
xyzzyzJulianSchmid
authored andcommitted
Fix lifetime syntax warnings in slices and iterators
1 parent 07f41cb commit 4b7103c

16 files changed

Lines changed: 28 additions & 26 deletions

etherparse/src/link/ethernet2_header_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a> Ethernet2HeaderSlice<'a> {
4343
/// [`Ethernet2Header::LEN`]
4444
#[inline]
4545
#[cfg(feature = "std")]
46-
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ethernet2HeaderSlice {
46+
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ethernet2HeaderSlice<'_> {
4747
debug_assert!(slice.len() == Ethernet2Header::LEN);
4848
Ethernet2HeaderSlice { slice }
4949
}

etherparse/src/link/linux_sll_header_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'a> LinuxSllHeaderSlice<'a> {
7272
/// [`LinuxSllHeader::LEN`] and the fields are valid
7373
#[inline]
7474
#[cfg(feature = "std")]
75-
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> LinuxSllHeaderSlice {
75+
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> LinuxSllHeaderSlice<'_> {
7676
debug_assert!(slice.len() == LinuxSllHeader::LEN);
7777
LinuxSllHeaderSlice { slice }
7878
}

etherparse/src/link/single_vlan_header_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a> SingleVlanHeaderSlice<'a> {
4343
/// The caller must ensured that the given slice has the length of
4444
/// [`SingleVlanHeader::LEN`]
4545
#[inline]
46-
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> SingleVlanHeaderSlice {
46+
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> SingleVlanHeaderSlice<'_> {
4747
SingleVlanHeaderSlice { slice }
4848
}
4949

etherparse/src/net/ip_slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum IpSlice<'a> {
1515

1616
impl<'a> IpSlice<'a> {
1717
/// Returns a reference to the `Ipv4Slice` if `self` is a `IpSlice::Ipv4`.
18-
pub fn ipv4(&self) -> Option<&Ipv4Slice> {
18+
pub fn ipv4(&self) -> Option<&Ipv4Slice<'_>> {
1919
use IpSlice::*;
2020
match self {
2121
Ipv4(slice) => Some(slice),
@@ -24,7 +24,7 @@ impl<'a> IpSlice<'a> {
2424
}
2525

2626
/// Returns a reference to the `Ipv6Slice` if `self` is a `IpSlice::Ipv6`.
27-
pub fn ipv6(&self) -> Option<&Ipv6Slice> {
27+
pub fn ipv6(&self) -> Option<&Ipv6Slice<'_>> {
2828
use IpSlice::*;
2929
match self {
3030
Ipv4(_) => None,
@@ -83,7 +83,7 @@ impl<'a> IpSlice<'a> {
8383
/// Separates and validates IP headers (including extension headers)
8484
/// in the given slice and determine the sub-slice containing the payload
8585
/// of the IP packet.
86-
pub fn from_slice(slice: &[u8]) -> Result<IpSlice, err::ip::SliceError> {
86+
pub fn from_slice(slice: &[u8]) -> Result<IpSlice<'_>, err::ip::SliceError> {
8787
use crate::ip_number::AUTH;
8888
use err::ip::{HeaderError::*, HeadersError::*, SliceError::*};
8989
use IpSlice::*;

etherparse/src/net/ipv4_header_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'a> Ipv4HeaderSlice<'a> {
8989
/// It must ensured that the slice exactly contains the IPv4 header
9090
/// and the ihl (intra header length) & total length must be consistent.
9191
#[inline]
92-
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ipv4HeaderSlice {
92+
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ipv4HeaderSlice<'_> {
9393
Ipv4HeaderSlice { slice }
9494
}
9595

etherparse/src/net/ipv4_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl core::hash::Hash for Ipv4Options {
141141

142142
impl core::cmp::PartialOrd for Ipv4Options {
143143
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
144-
Some(self.as_slice().cmp(other.as_slice()))
144+
Some(self.cmp(other))
145145
}
146146
}
147147

etherparse/src/net/ipv4_slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl<'a> Ipv4Slice<'a> {
2222
///
2323
/// If you want to ignore these kind of length errors based on the length
2424
/// fields in the IP headers use [`crate::LaxIpv4Slice::from_slice`] instead.
25-
pub fn from_slice(slice: &[u8]) -> Result<Ipv4Slice, SliceError> {
25+
pub fn from_slice(slice: &[u8]) -> Result<Ipv4Slice<'_>, SliceError> {
2626
use crate::ip_number::AUTH;
2727

2828
// decode the header
@@ -118,13 +118,13 @@ impl<'a> Ipv4Slice<'a> {
118118

119119
/// Returns a slice containing the IPv4 header.
120120
#[inline]
121-
pub fn header(&self) -> Ipv4HeaderSlice {
121+
pub fn header(&self) -> Ipv4HeaderSlice<'_> {
122122
self.header
123123
}
124124

125125
/// Returns a slice containing the IPv4 extension headers.
126126
#[inline]
127-
pub fn extensions(&self) -> Ipv4ExtensionsSlice {
127+
pub fn extensions(&self) -> Ipv4ExtensionsSlice<'_> {
128128
self.exts
129129
}
130130

etherparse/src/net/ipv6_header_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'a> Ipv6HeaderSlice<'a> {
5656
///
5757
/// It must ensured that the slice length is at least [`Ipv6Header::LEN`].
5858
#[inline]
59-
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ipv6HeaderSlice {
59+
pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ipv6HeaderSlice<'_> {
6060
Ipv6HeaderSlice { slice }
6161
}
6262

etherparse/src/net/lax_ip_slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub enum LaxIpSlice<'a> {
2424

2525
impl<'a> LaxIpSlice<'a> {
2626
/// Returns a reference to the `Ipv4Slice` if `self` is a `IpSlice::Ipv4`.
27-
pub fn ipv4(&self) -> Option<&LaxIpv4Slice> {
27+
pub fn ipv4(&self) -> Option<&LaxIpv4Slice<'_>> {
2828
use LaxIpSlice::*;
2929
match self {
3030
Ipv4(slice) => Some(slice),
@@ -33,7 +33,7 @@ impl<'a> LaxIpSlice<'a> {
3333
}
3434

3535
/// Returns a reference to the `Ipv6Slice` if `self` is a `IpSlice::Ipv6`.
36-
pub fn ipv6(&self) -> Option<&LaxIpv6Slice> {
36+
pub fn ipv6(&self) -> Option<&LaxIpv6Slice<'_>> {
3737
use LaxIpSlice::*;
3838
match self {
3939
Ipv4(_) => None,
@@ -141,7 +141,7 @@ impl<'a> LaxIpSlice<'a> {
141141
slice: &[u8],
142142
) -> Result<
143143
(
144-
LaxIpSlice,
144+
LaxIpSlice<'_>,
145145
Option<(err::ipv6_exts::HeaderSliceError, err::Layer)>,
146146
),
147147
err::ip::LaxHeaderSliceError,

etherparse/src/net/lax_ipv4_slice.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ impl<'a> LaxIpv4Slice<'a> {
7070
/// is set to [`LenSource::Ipv4HeaderTotalLen`].
7171
pub fn from_slice(
7272
slice: &[u8],
73-
) -> Result<(LaxIpv4Slice, Option<err::ip_auth::HeaderSliceError>), err::ipv4::HeaderSliceError>
74-
{
73+
) -> Result<
74+
(LaxIpv4Slice<'_>, Option<err::ip_auth::HeaderSliceError>),
75+
err::ipv4::HeaderSliceError,
76+
> {
7577
use crate::ip_number::AUTH;
7678

7779
// decode the header
@@ -197,13 +199,13 @@ impl<'a> LaxIpv4Slice<'a> {
197199

198200
/// Returns a slice containing the IPv4 header.
199201
#[inline]
200-
pub fn header(&self) -> Ipv4HeaderSlice {
202+
pub fn header(&self) -> Ipv4HeaderSlice<'_> {
201203
self.header
202204
}
203205

204206
/// Returns a slice containing the IPv4 extension headers.
205207
#[inline]
206-
pub fn extensions(&self) -> Ipv4ExtensionsSlice {
208+
pub fn extensions(&self) -> Ipv4ExtensionsSlice<'_> {
207209
self.exts
208210
}
209211

0 commit comments

Comments
 (0)