From 51d3fbb8fdcdce10a2ee77e23635d591c9cd0634 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 7 Jan 2026 20:03:47 +0100 Subject: [PATCH] Remove unnecessary explicit lifetimes Partially automated with cargo clippy --fix. --- src/byte_str.rs | 4 ++-- src/header/map.rs | 16 ++++++++-------- src/header/name.rs | 28 ++++++++++++++-------------- src/header/value.rs | 32 ++++++++++++++++---------------- src/method.rs | 24 ++++++++++++------------ src/status.rs | 12 ++++++------ src/uri/authority.rs | 20 ++++++++++---------- src/uri/mod.rs | 22 +++++++++++----------- src/uri/path.rs | 20 ++++++++++---------- src/uri/scheme.rs | 8 ++++---- 10 files changed, 93 insertions(+), 93 deletions(-) diff --git a/src/byte_str.rs b/src/byte_str.rs index e69bf0a8..f285e7f2 100644 --- a/src/byte_str.rs +++ b/src/byte_str.rs @@ -74,9 +74,9 @@ impl From for ByteStr { } } -impl<'a> From<&'a str> for ByteStr { +impl From<&str> for ByteStr { #[inline] - fn from(src: &'a str) -> ByteStr { + fn from(src: &str) -> ByteStr { ByteStr { // Invariant: src is a str so contains valid UTF-8. bytes: Bytes::copy_from_slice(src.as_bytes()), diff --git a/src/header/map.rs b/src/header/map.rs index aefbb003..85504d14 100644 --- a/src/header/map.rs +++ b/src/header/map.rs @@ -3758,7 +3758,7 @@ mod into_header_name { impl IntoHeaderName for HeaderName {} - impl<'a> Sealed for &'a HeaderName { + impl Sealed for &HeaderName { #[inline] fn try_insert( self, @@ -3778,7 +3778,7 @@ mod into_header_name { } } - impl<'a> IntoHeaderName for &'a HeaderName {} + impl IntoHeaderName for &HeaderName {} impl Sealed for &'static str { #[inline] @@ -3868,7 +3868,7 @@ mod as_header_name { impl AsHeaderName for HeaderName {} - impl<'a> Sealed for &'a HeaderName { + impl Sealed for &HeaderName { #[inline] fn try_entry(self, map: &mut HeaderMap) -> Result, TryEntryError> { Ok(map.try_entry2(self)?) @@ -3884,9 +3884,9 @@ mod as_header_name { } } - impl<'a> AsHeaderName for &'a HeaderName {} + impl AsHeaderName for &HeaderName {} - impl<'a> Sealed for &'a str { + impl Sealed for &str { #[inline] fn try_entry(self, map: &mut HeaderMap) -> Result, TryEntryError> { Ok(HdrName::from_bytes(self.as_bytes(), move |hdr| { @@ -3904,7 +3904,7 @@ mod as_header_name { } } - impl<'a> AsHeaderName for &'a str {} + impl AsHeaderName for &str {} impl Sealed for String { #[inline] @@ -3924,7 +3924,7 @@ mod as_header_name { impl AsHeaderName for String {} - impl<'a> Sealed for &'a String { + impl Sealed for &String { #[inline] fn try_entry(self, map: &mut HeaderMap) -> Result, TryEntryError> { self.as_str().try_entry(map) @@ -3940,7 +3940,7 @@ mod as_header_name { } } - impl<'a> AsHeaderName for &'a String {} + impl AsHeaderName for &String {} } #[test] diff --git a/src/header/name.rs b/src/header/name.rs index 1b4a39d6..02af57e1 100644 --- a/src/header/name.rs +++ b/src/header/name.rs @@ -1319,8 +1319,8 @@ impl InvalidHeaderName { } } -impl<'a> From<&'a HeaderName> for HeaderName { - fn from(src: &'a HeaderName) -> HeaderName { +impl From<&HeaderName> for HeaderName { + fn from(src: &HeaderName) -> HeaderName { src.clone() } } @@ -1345,26 +1345,26 @@ impl From for Bytes { } } -impl<'a> TryFrom<&'a str> for HeaderName { +impl TryFrom<&str> for HeaderName { type Error = InvalidHeaderName; #[inline] - fn try_from(s: &'a str) -> Result { + fn try_from(s: &str) -> Result { Self::from_bytes(s.as_bytes()) } } -impl<'a> TryFrom<&'a String> for HeaderName { +impl TryFrom<&String> for HeaderName { type Error = InvalidHeaderName; #[inline] - fn try_from(s: &'a String) -> Result { + fn try_from(s: &String) -> Result { Self::from_bytes(s.as_bytes()) } } -impl<'a> TryFrom<&'a [u8]> for HeaderName { +impl TryFrom<&[u8]> for HeaderName { type Error = InvalidHeaderName; #[inline] - fn try_from(s: &'a [u8]) -> Result { + fn try_from(s: &[u8]) -> Result { Self::from_bytes(s) } } @@ -1405,14 +1405,14 @@ impl From for HeaderName { } } -impl<'a> PartialEq<&'a HeaderName> for HeaderName { +impl PartialEq<&HeaderName> for HeaderName { #[inline] - fn eq(&self, other: &&'a HeaderName) -> bool { + fn eq(&self, other: &&HeaderName) -> bool { *self == **other } } -impl<'a> PartialEq for &'a HeaderName { +impl PartialEq for &HeaderName { #[inline] fn eq(&self, other: &HeaderName) -> bool { *other == *self @@ -1457,16 +1457,16 @@ impl PartialEq for str { } } -impl<'a> PartialEq<&'a str> for HeaderName { +impl PartialEq<&str> for HeaderName { /// Performs a case-insensitive comparison of the string against the header /// name #[inline] - fn eq(&self, other: &&'a str) -> bool { + fn eq(&self, other: &&str) -> bool { *self == **other } } -impl<'a> PartialEq for &'a str { +impl PartialEq for &str { /// Performs a case-insensitive comparison of the string against the header /// name #[inline] diff --git a/src/header/value.rs b/src/header/value.rs index 48308cb4..abd5d036 100644 --- a/src/header/value.rs +++ b/src/header/value.rs @@ -484,35 +484,35 @@ impl FromStr for HeaderValue { } } -impl<'a> From<&'a HeaderValue> for HeaderValue { +impl From<&HeaderValue> for HeaderValue { #[inline] - fn from(t: &'a HeaderValue) -> Self { + fn from(t: &HeaderValue) -> Self { t.clone() } } -impl<'a> TryFrom<&'a str> for HeaderValue { +impl TryFrom<&str> for HeaderValue { type Error = InvalidHeaderValue; #[inline] - fn try_from(t: &'a str) -> Result { + fn try_from(t: &str) -> Result { t.parse() } } -impl<'a> TryFrom<&'a String> for HeaderValue { +impl TryFrom<&String> for HeaderValue { type Error = InvalidHeaderValue; #[inline] - fn try_from(s: &'a String) -> Result { + fn try_from(s: &String) -> Result { Self::from_bytes(s.as_bytes()) } } -impl<'a> TryFrom<&'a [u8]> for HeaderValue { +impl TryFrom<&[u8]> for HeaderValue { type Error = InvalidHeaderValue; #[inline] - fn try_from(t: &'a [u8]) -> Result { + fn try_from(t: &[u8]) -> Result { HeaderValue::from_bytes(t) } } @@ -697,48 +697,48 @@ impl PartialOrd for String { } } -impl<'a> PartialEq for &'a HeaderValue { +impl PartialEq for &HeaderValue { #[inline] fn eq(&self, other: &HeaderValue) -> bool { **self == *other } } -impl<'a> PartialOrd for &'a HeaderValue { +impl PartialOrd for &HeaderValue { #[inline] fn partial_cmp(&self, other: &HeaderValue) -> Option { (**self).partial_cmp(other) } } -impl<'a, T: ?Sized> PartialEq<&'a T> for HeaderValue +impl PartialEq<&T> for HeaderValue where HeaderValue: PartialEq, { #[inline] - fn eq(&self, other: &&'a T) -> bool { + fn eq(&self, other: &&T) -> bool { *self == **other } } -impl<'a, T: ?Sized> PartialOrd<&'a T> for HeaderValue +impl PartialOrd<&T> for HeaderValue where HeaderValue: PartialOrd, { #[inline] - fn partial_cmp(&self, other: &&'a T) -> Option { + fn partial_cmp(&self, other: &&T) -> Option { self.partial_cmp(*other) } } -impl<'a> PartialEq for &'a str { +impl PartialEq for &str { #[inline] fn eq(&self, other: &HeaderValue) -> bool { *other == *self } } -impl<'a> PartialOrd for &'a str { +impl PartialOrd for &str { #[inline] fn partial_cmp(&self, other: &HeaderValue) -> Option { self.as_bytes().partial_cmp(other.as_bytes()) diff --git a/src/method.rs b/src/method.rs index 7b4584ab..3f2c6bcb 100644 --- a/src/method.rs +++ b/src/method.rs @@ -187,14 +187,14 @@ impl AsRef for Method { } } -impl<'a> PartialEq<&'a Method> for Method { +impl PartialEq<&Method> for Method { #[inline] - fn eq(&self, other: &&'a Method) -> bool { + fn eq(&self, other: &&Method) -> bool { self == *other } } -impl<'a> PartialEq for &'a Method { +impl PartialEq for &Method { #[inline] fn eq(&self, other: &Method) -> bool { *self == other @@ -215,14 +215,14 @@ impl PartialEq for str { } } -impl<'a> PartialEq<&'a str> for Method { +impl PartialEq<&str> for Method { #[inline] - fn eq(&self, other: &&'a str) -> bool { + fn eq(&self, other: &&str) -> bool { self.as_ref() == *other } } -impl<'a> PartialEq for &'a str { +impl PartialEq for &str { #[inline] fn eq(&self, other: &Method) -> bool { *self == other.as_ref() @@ -248,27 +248,27 @@ impl Default for Method { } } -impl<'a> From<&'a Method> for Method { +impl From<&Method> for Method { #[inline] - fn from(t: &'a Method) -> Self { + fn from(t: &Method) -> Self { t.clone() } } -impl<'a> TryFrom<&'a [u8]> for Method { +impl TryFrom<&[u8]> for Method { type Error = InvalidMethod; #[inline] - fn try_from(t: &'a [u8]) -> Result { + fn try_from(t: &[u8]) -> Result { Method::from_bytes(t) } } -impl<'a> TryFrom<&'a str> for Method { +impl TryFrom<&str> for Method { type Error = InvalidMethod; #[inline] - fn try_from(t: &'a str) -> Result { + fn try_from(t: &str) -> Result { TryFrom::try_from(t.as_bytes()) } } diff --git a/src/status.rs b/src/status.rs index bc58ba45..aa9dc308 100644 --- a/src/status.rs +++ b/src/status.rs @@ -263,27 +263,27 @@ impl FromStr for StatusCode { } } -impl<'a> From<&'a StatusCode> for StatusCode { +impl From<&StatusCode> for StatusCode { #[inline] - fn from(t: &'a StatusCode) -> Self { + fn from(t: &StatusCode) -> Self { t.to_owned() } } -impl<'a> TryFrom<&'a [u8]> for StatusCode { +impl TryFrom<&[u8]> for StatusCode { type Error = InvalidStatusCode; #[inline] - fn try_from(t: &'a [u8]) -> Result { + fn try_from(t: &[u8]) -> Result { StatusCode::from_bytes(t) } } -impl<'a> TryFrom<&'a str> for StatusCode { +impl TryFrom<&str> for StatusCode { type Error = InvalidStatusCode; #[inline] - fn try_from(t: &'a str) -> Result { + fn try_from(t: &str) -> Result { t.parse() } } diff --git a/src/uri/authority.rs b/src/uri/authority.rs index 67754e45..c5479cb2 100644 --- a/src/uri/authority.rs +++ b/src/uri/authority.rs @@ -244,14 +244,14 @@ impl PartialEq for str { } } -impl<'a> PartialEq for &'a str { +impl PartialEq for &str { fn eq(&self, other: &Authority) -> bool { self.eq_ignore_ascii_case(other.as_str()) } } -impl<'a> PartialEq<&'a str> for Authority { - fn eq(&self, other: &&'a str) -> bool { +impl PartialEq<&str> for Authority { + fn eq(&self, other: &&str) -> bool { self.data.eq_ignore_ascii_case(other) } } @@ -302,7 +302,7 @@ impl PartialOrd for str { } } -impl<'a> PartialOrd for &'a str { +impl PartialOrd for &str { fn partial_cmp(&self, other: &Authority) -> Option { let left = self.as_bytes().iter().map(|b| b.to_ascii_lowercase()); let right = other.data.as_bytes().iter().map(|b| b.to_ascii_lowercase()); @@ -310,8 +310,8 @@ impl<'a> PartialOrd for &'a str { } } -impl<'a> PartialOrd<&'a str> for Authority { - fn partial_cmp(&self, other: &&'a str) -> Option { +impl PartialOrd<&str> for Authority { + fn partial_cmp(&self, other: &&str) -> Option { let left = self.data.as_bytes().iter().map(|b| b.to_ascii_lowercase()); let right = other.as_bytes().iter().map(|b| b.to_ascii_lowercase()); left.partial_cmp(right) @@ -368,10 +368,10 @@ impl Hash for Authority { } } -impl<'a> TryFrom<&'a [u8]> for Authority { +impl TryFrom<&[u8]> for Authority { type Error = InvalidUri; #[inline] - fn try_from(s: &'a [u8]) -> Result { + fn try_from(s: &[u8]) -> Result { // parse first, and only turn into Bytes if valid // Preconditon on create_authority: copy_from_slice() copies all of @@ -380,10 +380,10 @@ impl<'a> TryFrom<&'a [u8]> for Authority { } } -impl<'a> TryFrom<&'a str> for Authority { +impl TryFrom<&str> for Authority { type Error = InvalidUri; #[inline] - fn try_from(s: &'a str) -> Result { + fn try_from(s: &str) -> Result { TryFrom::try_from(s.as_bytes()) } } diff --git a/src/uri/mod.rs b/src/uri/mod.rs index 767f0743..eb7781a8 100644 --- a/src/uri/mod.rs +++ b/src/uri/mod.rs @@ -705,29 +705,29 @@ impl Uri { } } -impl<'a> TryFrom<&'a [u8]> for Uri { +impl TryFrom<&[u8]> for Uri { type Error = InvalidUri; #[inline] - fn try_from(t: &'a [u8]) -> Result { + fn try_from(t: &[u8]) -> Result { Uri::from_shared(Bytes::copy_from_slice(t)) } } -impl<'a> TryFrom<&'a str> for Uri { +impl TryFrom<&str> for Uri { type Error = InvalidUri; #[inline] - fn try_from(t: &'a str) -> Result { + fn try_from(t: &str) -> Result { t.parse() } } -impl<'a> TryFrom<&'a String> for Uri { +impl TryFrom<&String> for Uri { type Error = InvalidUri; #[inline] - fn try_from(t: &'a String) -> Result { + fn try_from(t: &String) -> Result { t.parse() } } @@ -759,11 +759,11 @@ impl TryFrom for Uri { } } -impl<'a> TryFrom<&'a Uri> for Uri { +impl TryFrom<&Uri> for Uri { type Error = crate::Error; #[inline] - fn try_from(src: &'a Uri) -> Result { + fn try_from(src: &Uri) -> Result { Ok(src.clone()) } } @@ -995,13 +995,13 @@ impl PartialEq for str { } } -impl<'a> PartialEq<&'a str> for Uri { - fn eq(&self, other: &&'a str) -> bool { +impl PartialEq<&str> for Uri { + fn eq(&self, other: &&str) -> bool { self == *other } } -impl<'a> PartialEq for &'a str { +impl PartialEq for &str { fn eq(&self, uri: &Uri) -> bool { uri == *self } diff --git a/src/uri/path.rs b/src/uri/path.rs index 8f9356e8..058aae07 100644 --- a/src/uri/path.rs +++ b/src/uri/path.rs @@ -304,18 +304,18 @@ impl PathAndQuery { } } -impl<'a> TryFrom<&'a [u8]> for PathAndQuery { +impl TryFrom<&[u8]> for PathAndQuery { type Error = InvalidUri; #[inline] - fn try_from(s: &'a [u8]) -> Result { + fn try_from(s: &[u8]) -> Result { PathAndQuery::from_shared(Bytes::copy_from_slice(s)) } } -impl<'a> TryFrom<&'a str> for PathAndQuery { +impl TryFrom<&str> for PathAndQuery { type Error = InvalidUri; #[inline] - fn try_from(s: &'a str) -> Result { + fn try_from(s: &str) -> Result { TryFrom::try_from(s.as_bytes()) } } @@ -395,16 +395,16 @@ impl PartialEq for PathAndQuery { } } -impl<'a> PartialEq for &'a str { +impl PartialEq for &str { #[inline] fn eq(&self, other: &PathAndQuery) -> bool { self == &other.as_str() } } -impl<'a> PartialEq<&'a str> for PathAndQuery { +impl PartialEq<&str> for PathAndQuery { #[inline] - fn eq(&self, other: &&'a str) -> bool { + fn eq(&self, other: &&str) -> bool { self.as_str() == *other } } @@ -451,14 +451,14 @@ impl PartialOrd for str { } } -impl<'a> PartialOrd<&'a str> for PathAndQuery { +impl PartialOrd<&str> for PathAndQuery { #[inline] - fn partial_cmp(&self, other: &&'a str) -> Option { + fn partial_cmp(&self, other: &&str) -> Option { self.as_str().partial_cmp(*other) } } -impl<'a> PartialOrd for &'a str { +impl PartialOrd for &str { #[inline] fn partial_cmp(&self, other: &PathAndQuery) -> Option { self.partial_cmp(&other.as_str()) diff --git a/src/uri/scheme.rs b/src/uri/scheme.rs index dbcc8c3f..bf4d59c3 100644 --- a/src/uri/scheme.rs +++ b/src/uri/scheme.rs @@ -67,10 +67,10 @@ impl Scheme { } } -impl<'a> TryFrom<&'a [u8]> for Scheme { +impl TryFrom<&[u8]> for Scheme { type Error = InvalidUri; #[inline] - fn try_from(s: &'a [u8]) -> Result { + fn try_from(s: &[u8]) -> Result { use self::Scheme2::*; match Scheme2::parse_exact(s)? { @@ -89,10 +89,10 @@ impl<'a> TryFrom<&'a [u8]> for Scheme { } } -impl<'a> TryFrom<&'a str> for Scheme { +impl TryFrom<&str> for Scheme { type Error = InvalidUri; #[inline] - fn try_from(s: &'a str) -> Result { + fn try_from(s: &str) -> Result { TryFrom::try_from(s.as_bytes()) } }