1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-01-18 05:41:50 +01:00

chore: address clippy warnings

This commit is contained in:
Rob Ede 2024-12-29 15:03:43 +00:00
parent 472dbca64e
commit 34327bd221
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
10 changed files with 19 additions and 14 deletions

View File

@ -830,7 +830,7 @@ impl<'a> Drain<'a> {
} }
} }
impl<'a> Iterator for Drain<'a> { impl Iterator for Drain<'_> {
type Item = (Option<HeaderName>, HeaderValue); type Item = (Option<HeaderName>, HeaderValue);
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View File

@ -61,7 +61,7 @@ pub fn write_content_length<B: BufMut>(n: u64, buf: &mut B, camel_case: bool) {
/// perform a remaining length check before writing. /// perform a remaining length check before writing.
pub(crate) struct MutWriter<'a, B>(pub(crate) &'a mut B); pub(crate) struct MutWriter<'a, B>(pub(crate) &'a mut B);
impl<'a, B> io::Write for MutWriter<'a, B> impl<B> io::Write for MutWriter<'_, B>
where where
B: BufMut, B: BufMut,
{ {

View File

@ -103,7 +103,7 @@ pub trait HttpMessage: Sized {
} }
} }
impl<'a, T> HttpMessage for &'a mut T impl<T> HttpMessage for &mut T
where where
T: HttpMessage, T: HttpMessage,
{ {

View File

@ -19,7 +19,7 @@ impl ResourcePath for String {
} }
} }
impl<'a> ResourcePath for &'a str { impl ResourcePath for &str {
fn path(&self) -> &str { fn path(&self) -> &str {
self self
} }

View File

@ -136,7 +136,7 @@ async fn routes_overlapping_inaccessible_test(req: HttpRequest) -> impl Responde
} }
#[get("/custom_resource_name", name = "custom")] #[get("/custom_resource_name", name = "custom")]
async fn custom_resource_name_test<'a>(req: HttpRequest) -> impl Responder { async fn custom_resource_name_test(req: HttpRequest) -> impl Responder {
assert!(req.url_for_static("custom").is_ok()); assert!(req.url_for_static("custom").is_ok());
assert!(req.url_for_static("custom_resource_name_test").is_err()); assert!(req.url_for_static("custom_resource_name_test").is_err());
HttpResponse::Ok() HttpResponse::Ok()

View File

@ -10,7 +10,7 @@ use bytes::BufMut;
/// perform a remaining length check before writing. /// perform a remaining length check before writing.
pub(crate) struct MutWriter<'a, B>(pub(crate) &'a mut B); pub(crate) struct MutWriter<'a, B>(pub(crate) &'a mut B);
impl<'a, B> io::Write for MutWriter<'a, B> impl<B> io::Write for MutWriter<'_, B>
where where
B: BufMut, B: BufMut,
{ {

View File

@ -704,7 +704,7 @@ impl FormatText {
/// Converter to get a String from something that writes to a Formatter. /// Converter to get a String from something that writes to a Formatter.
pub(crate) struct FormatDisplay<'a>(&'a dyn Fn(&mut fmt::Formatter<'_>) -> Result<(), fmt::Error>); pub(crate) struct FormatDisplay<'a>(&'a dyn Fn(&mut fmt::Formatter<'_>) -> Result<(), fmt::Error>);
impl<'a> fmt::Display for FormatDisplay<'a> { impl fmt::Display for FormatDisplay<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
(self.0)(fmt) (self.0)(fmt)
} }

View File

@ -332,7 +332,7 @@ impl<T: DeserializeOwned> JsonBody<T> {
(true, Ok(Some(mime))) => { (true, Ok(Some(mime))) => {
mime.subtype() == mime::JSON mime.subtype() == mime::JSON
|| mime.suffix() == Some(mime::JSON) || mime.suffix() == Some(mime::JSON)
|| ctype_fn.map_or(false, |predicate| predicate(mime)) || ctype_fn.is_some_and(|predicate| predicate(mime))
} }
// if content-type is expected but not parsable as mime type, bail // if content-type is expected but not parsable as mime type, bail

View File

@ -511,7 +511,8 @@ where
let h2 = sock let h2 = sock
.ssl() .ssl()
.selected_alpn_protocol() .selected_alpn_protocol()
.map_or(false, |protos| protos.windows(2).any(|w| w == H2)); .is_some_and(|protos| protos.windows(2).any(|w| w == H2));
if h2 { if h2 {
(Box::new(sock), Protocol::Http2) (Box::new(sock), Protocol::Http2)
} else { } else {
@ -550,7 +551,8 @@ where
.get_ref() .get_ref()
.1 .1
.alpn_protocol() .alpn_protocol()
.map_or(false, |protos| protos.windows(2).any(|w| w == H2)); .is_some_and(|protos| protos.windows(2).any(|w| w == H2));
if h2 { if h2 {
(Box::new(sock), Protocol::Http2) (Box::new(sock), Protocol::Http2)
} else { } else {
@ -584,7 +586,8 @@ where
.get_ref() .get_ref()
.1 .1
.alpn_protocol() .alpn_protocol()
.map_or(false, |protos| protos.windows(2).any(|w| w == H2)); .is_some_and(|protos| protos.windows(2).any(|w| w == H2));
if h2 { if h2 {
(Box::new(sock), Protocol::Http2) (Box::new(sock), Protocol::Http2)
} else { } else {
@ -621,7 +624,8 @@ where
.get_ref() .get_ref()
.1 .1
.alpn_protocol() .alpn_protocol()
.map_or(false, |protos| protos.windows(2).any(|w| w == H2)); .is_some_and(|protos| protos.windows(2).any(|w| w == H2));
if h2 { if h2 {
(Box::new(sock), Protocol::Http2) (Box::new(sock), Protocol::Http2)
} else { } else {
@ -655,7 +659,8 @@ where
.get_ref() .get_ref()
.1 .1
.alpn_protocol() .alpn_protocol()
.map_or(false, |protos| protos.windows(2).any(|w| w == H2)); .is_some_and(|protos| protos.windows(2).any(|w| w == H2));
if h2 { if h2 {
(Box::new(sock), Protocol::Http2) (Box::new(sock), Protocol::Http2)
} else { } else {

View File

@ -444,7 +444,7 @@ struct Host<'a> {
port: Option<http::uri::Port<&'a str>>, port: Option<http::uri::Port<&'a str>>,
} }
impl<'a> fmt::Display for Host<'a> { impl fmt::Display for Host<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.hostname)?; f.write_str(self.hostname)?;