diff --git a/src/header/map.rs b/src/header/map.rs index af6b623b..24b307dc 100644 --- a/src/header/map.rs +++ b/src/header/map.rs @@ -1497,7 +1497,7 @@ impl HeaderMap { #[inline] fn find(&self, key: &K) -> Option<(usize, usize)> where - K: Hash + Into + ?Sized, + K: Hash + Into, HeaderName: PartialEq, { if self.entries.is_empty() { @@ -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..f2436e45 100644 --- a/src/header/name.rs +++ b/src/header/name.rs @@ -1412,7 +1412,7 @@ impl<'a> PartialEq<&'a HeaderName> for HeaderName { } } -impl<'a> PartialEq for &'a HeaderName { +impl PartialEq for &HeaderName { #[inline] fn eq(&self, other: &HeaderName) -> bool { *other == *self @@ -1466,7 +1466,7 @@ impl<'a> PartialEq<&'a str> for HeaderName { } } -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..9e751a6a 100644 --- a/src/header/value.rs +++ b/src/header/value.rs @@ -411,7 +411,7 @@ macro_rules! from_integers { let val = HeaderValue::from(n); assert_eq!(val, &n.to_string()); - let n = ::std::$t::MAX; + let n = $t::MAX; let val = HeaderValue::from(n); assert_eq!(val, &n.to_string()); } @@ -543,7 +543,7 @@ mod try_from_header_name_tests { #[test] fn it_converts_using_try_from() { assert_eq!( - HeaderValue::try_from(name::UPGRADE).unwrap(), + HeaderValue::from(name::UPGRADE), HeaderValue::from_bytes(b"upgrade").unwrap() ); } @@ -697,14 +697,14 @@ 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) @@ -731,14 +731,14 @@ where } } -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..2567b739 100644 --- a/src/method.rs +++ b/src/method.rs @@ -194,7 +194,7 @@ impl<'a> PartialEq<&'a Method> for Method { } } -impl<'a> PartialEq for &'a Method { +impl PartialEq for &Method { #[inline] fn eq(&self, other: &Method) -> bool { *self == other @@ -222,7 +222,7 @@ impl<'a> PartialEq<&'a str> for Method { } } -impl<'a> PartialEq for &'a str { +impl PartialEq for &str { #[inline] fn eq(&self, other: &Method) -> bool { *self == other.as_ref() diff --git a/src/uri/authority.rs b/src/uri/authority.rs index 67754e45..4ca07e23 100644 --- a/src/uri/authority.rs +++ b/src/uri/authority.rs @@ -244,7 +244,7 @@ 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()) } @@ -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()); @@ -660,10 +660,10 @@ mod tests { #[test] fn compares_with_a_string() { let authority: Authority = "def.com".parse().unwrap(); - assert!(authority < "ghi.com".to_string()); - assert!("ghi.com".to_string() > authority); - assert!(authority > "abc.com".to_string()); - assert!("abc.com".to_string() < authority); + assert!(authority < "ghi.com"); + assert!("ghi.com" > authority); + assert!(authority > "abc.com"); + assert!("abc.com" < authority); } #[test] diff --git a/src/uri/mod.rs b/src/uri/mod.rs index 767f0743..ff9908e9 100644 --- a/src/uri/mod.rs +++ b/src/uri/mod.rs @@ -1001,7 +1001,7 @@ impl<'a> PartialEq<&'a str> for Uri { } } -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..39a0db14 100644 --- a/src/uri/path.rs +++ b/src/uri/path.rs @@ -395,7 +395,7 @@ 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() @@ -458,7 +458,7 @@ impl<'a> PartialOrd<&'a str> for PathAndQuery { } } -impl<'a> PartialOrd for &'a str { +impl PartialOrd for &str { #[inline] fn partial_cmp(&self, other: &PathAndQuery) -> Option { self.partial_cmp(&other.as_str()) @@ -620,10 +620,10 @@ mod tests { #[test] fn compares_with_a_string() { let path_and_query: PathAndQuery = "/b/world&foo=bar".parse().unwrap(); - assert!(path_and_query < "/c/world&foo=bar".to_string()); - assert!("/c/world&foo=bar".to_string() > path_and_query); - assert!(path_and_query > "/a/world&foo=bar".to_string()); - assert!("/a/world&foo=bar".to_string() < path_and_query); + assert!(path_and_query < "/c/world&foo=bar"); + assert!("/c/world&foo=bar" > path_and_query); + assert!(path_and_query > "/a/world&foo=bar"); + assert!("/a/world&foo=bar" < path_and_query); } #[test] @@ -671,6 +671,6 @@ mod tests { } fn pq(s: &str) -> PathAndQuery { - s.parse().expect(&format!("parsing {}", s)) + s.parse().unwrap_or_else(|_| panic!("parsing {s}")) } } diff --git a/src/uri/scheme.rs b/src/uri/scheme.rs index dbcc8c3f..47a8bb1c 100644 --- a/src/uri/scheme.rs +++ b/src/uri/scheme.rs @@ -356,6 +356,6 @@ mod test { } fn scheme(s: &str) -> Scheme { - s.parse().expect(&format!("Invalid scheme: {}", s)) + s.parse().unwrap_or_else(|_| panic!("Invalid scheme: {s}")) } } diff --git a/tests/header_map.rs b/tests/header_map.rs index 9a9d7e12..3dfbf25d 100644 --- a/tests/header_map.rs +++ b/tests/header_map.rs @@ -60,7 +60,7 @@ fn with_capacity_overflow() { fn reserve_overflow() { // See https://github.com/hyperium/http/issues/352 let mut headers = HeaderMap::::with_capacity(0); - headers.reserve(std::usize::MAX); // next_power_of_two overflows + headers.reserve(usize::MAX); // next_power_of_two overflows } #[test]