From 4c06798b728bc4540fe2054c726d0b453ed286db Mon Sep 17 00:00:00 2001 From: Sunli Date: Fri, 5 Jan 2024 22:18:52 +0800 Subject: [PATCH] clippy clean --- poem-grpc/src/client.rs | 2 +- poem-grpc/src/encoding.rs | 4 ++-- poem/src/listener/acme/jose.rs | 4 ++-- poem/src/listener/rustls.rs | 4 ++-- poem/src/request.rs | 2 +- poem/src/server.rs | 1 - 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/poem-grpc/src/client.rs b/poem-grpc/src/client.rs index 1f146b29ad..dbef21c1b2 100644 --- a/poem-grpc/src/client.rs +++ b/poem-grpc/src/client.rs @@ -440,7 +440,7 @@ fn create_client_endpoint( Ok::<_, poem::Error>(HttpResponse::from(hyper::Response::from_parts( parts, - body.map_err(|err| IoError::other(err)), + body.map_err(IoError::other), ))) } })) diff --git a/poem-grpc/src/encoding.rs b/poem-grpc/src/encoding.rs index e9d3e33e77..39ffec5766 100644 --- a/poem-grpc/src/encoding.rs +++ b/poem-grpc/src/encoding.rs @@ -136,7 +136,7 @@ pub(crate) fn create_encode_response_body( }); BodyExt::boxed(StreamBody::new( - ReceiverStream::new(rx).map(|frame| Ok::<_, IoError>(frame)), + ReceiverStream::new(rx).map(Ok::<_, IoError>), )) .into() } @@ -160,7 +160,7 @@ pub(crate) fn create_encode_request_body( }); BodyExt::boxed(StreamBody::new( - ReceiverStream::new(rx).map(|frame| Ok::<_, IoError>(frame)), + ReceiverStream::new(rx).map(Ok::<_, IoError>), )) .into() } diff --git a/poem/src/listener/acme/jose.rs b/poem/src/listener/acme/jose.rs index 17564ad010..58767b2289 100644 --- a/poem/src/listener/acme/jose.rs +++ b/poem/src/listener/acme/jose.rs @@ -109,7 +109,7 @@ pub(crate) async fn request( None => Some(Jwk::new(key_pair)), Some(_) => None, }; - let protected = Protected::base64(jwk, kid, nonce, &uri.to_string())?; + let protected = Protected::base64(jwk, kid, nonce, uri)?; let payload = match payload { Some(payload) => serde_json::to_vec(&payload).map_err(|err| { IoError::new(ErrorKind::Other, format!("failed to encode payload: {err}")) @@ -145,7 +145,7 @@ pub(crate) async fn request( format!("unexpected status code: status = {}", resp.status()), )); } - Ok(resp.into()) + Ok(resp) } pub(crate) async fn request_json( diff --git a/poem/src/listener/rustls.rs b/poem/src/listener/rustls.rs index b38e6c83f7..445123dc3c 100644 --- a/poem/src/listener/rustls.rs +++ b/poem/src/listener/rustls.rs @@ -245,14 +245,14 @@ impl RustlsConfig { WebPkiClientVerifier::builder(read_trust_anchor(trust_anchor)?.into()) .allow_unauthenticated() .build() - .map_err(|err| IoError::other(err))?; + .map_err(IoError::other)?; builder.with_client_cert_verifier(verifier) } TlsClientAuth::Required(trust_anchor) => { let verifier = WebPkiClientVerifier::builder(read_trust_anchor(trust_anchor)?.into()) .build() - .map_err(|err| IoError::other(err))?; + .map_err(IoError::other)?; builder.with_client_cert_verifier(verifier) } }; diff --git a/poem/src/request.rs b/poem/src/request.rs index e8bbd5e018..e0416d6d66 100644 --- a/poem/src/request.rs +++ b/poem/src/request.rs @@ -132,7 +132,7 @@ impl From<(http::Request, LocalAddr, RemoteAddr, Scheme)> for Request version: parts.version, headers: parts.headers, extensions: parts.extensions, - body: Body(body.map_err(|err| Error::other(err)).boxed()), + body: Body(body.map_err(Error::other).boxed()), state: RequestState { local_addr, remote_addr, diff --git a/poem/src/server.rs b/poem/src/server.rs index 5f3b9c60a3..824340fd0b 100644 --- a/poem/src/server.rs +++ b/poem/src/server.rs @@ -361,7 +361,6 @@ async fn serve_connection( tokio::select! { _ = conn => { // Connection completed successfully. - return; }, _ = connection_shutdown_token.cancelled() => { tracing::info!(remote_addr=%remote_addr, "closing connection due to inactivity");