From fa6b098056815578ca5d8257d59c03c0a59f8c02 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Tue, 16 Jun 2020 17:51:50 -0700 Subject: [PATCH] cleanup clippy warnings (#495) Co-authored-by: Jane Lusby --- tower-batch/src/service.rs | 2 +- tower-batch/tests/ed25519.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tower-batch/src/service.rs b/tower-batch/src/service.rs index 0b9b7cf9..28c4e713 100644 --- a/tower-batch/src/service.rs +++ b/tower-batch/src/service.rs @@ -67,7 +67,7 @@ where fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { // If the inner service has errored, then we error here. - if let Err(_) = ready!(self.tx.poll_ready(cx)) { + if ready!(self.tx.poll_ready(cx)).is_err() { Poll::Ready(Err(self.get_worker_error())) } else { Poll::Ready(Ok(())) diff --git a/tower-batch/tests/ed25519.rs b/tower-batch/tests/ed25519.rs index 14be38cf..d1599fc5 100644 --- a/tower-batch/tests/ed25519.rs +++ b/tower-batch/tests/ed25519.rs @@ -1,5 +1,6 @@ use std::{ future::Future, + mem, pin::Pin, sync::Once, task::{Context, Poll}, @@ -24,6 +25,7 @@ pub struct Ed25519Verifier { tx: Sender>, } +#[allow(clippy::new_without_default)] impl Ed25519Verifier { pub fn new() -> Self { let batch = batch::Verifier::default(); @@ -65,7 +67,7 @@ impl<'msg> Service> for Ed25519Verifier { } BatchControl::Flush => { tracing::trace!("got flush command"); - let batch = std::mem::replace(&mut self.batch, batch::Verifier::default()); + let batch = mem::take(&mut self.batch); let _ = self.tx.send(batch.verify(thread_rng())); Box::pin(async { Ok(()) }) } @@ -76,7 +78,7 @@ impl<'msg> Service> for Ed25519Verifier { impl Drop for Ed25519Verifier { fn drop(&mut self) { // We need to flush the current batch in case there are still any pending futures. - let batch = std::mem::replace(&mut self.batch, batch::Verifier::default()); + let batch = mem::take(&mut self.batch); let _ = self.tx.send(batch.verify(thread_rng())); } }