chore(util): remove redundant ready! wrapping in poll implementations (#844)

This commit is contained in:
Kirill Rudakov 2025-12-07 15:31:29 +03:00 committed by GitHub
parent 21e01e977e
commit 1992ebd196
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 11 deletions

View File

@ -5,7 +5,7 @@ use pin_project_lite::pin_project;
use std::{
future::Future,
pin::Pin,
task::{ready, Context, Poll},
task::{Context, Poll},
};
use tokio::sync::OwnedSemaphorePermit;
@ -35,6 +35,6 @@ where
type Output = Result<T, E>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Ready(ready!(self.project().inner.poll(cx)))
self.project().inner.poll(cx)
}
}

View File

@ -2,7 +2,7 @@ use super::Rate;
use std::{
future::Future,
pin::Pin,
task::{ready, Context, Poll},
task::{Context, Poll},
};
use tokio::time::{Instant, Sleep};
use tower_service::Service;
@ -70,7 +70,7 @@ where
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
match self.state {
State::Ready { .. } => return Poll::Ready(ready!(self.inner.poll_ready(cx))),
State::Ready { .. } => return self.inner.poll_ready(cx),
State::Limited => {
if Pin::new(&mut self.sleep).poll(cx).is_pending() {
tracing::trace!("rate limit exceeded; sleeping.");
@ -84,7 +84,7 @@ where
rem: self.rate.num(),
};
Poll::Ready(ready!(self.inner.poll_ready(cx)))
self.inner.poll_ready(cx)
}
fn call(&mut self, request: Request) -> Self::Future {

View File

@ -3,7 +3,7 @@
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::task::{ready, Context, Poll};
use std::task::{Context, Poll};
use pin_project_lite::pin_project;
@ -53,9 +53,7 @@ where
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match self.project().state.project() {
ResponseStateProj::Called { fut } => {
Poll::Ready(ready!(fut.poll(cx)).map_err(Into::into))
}
ResponseStateProj::Called { fut } => fut.poll(cx).map_err(Into::into),
ResponseStateProj::Overloaded => Poll::Ready(Err(Overloaded::new().into())),
}
}

View File

@ -3,7 +3,7 @@ use pin_project_lite::pin_project;
use std::{
future::Future,
pin::Pin,
task::{ready, Context, Poll},
task::{Context, Poll},
};
pin_project! {
@ -32,7 +32,7 @@ where
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match self.project().inner.as_pin_mut() {
Some(inner) => Poll::Ready(Ok(ready!(inner.poll(cx)).map_err(Into::into)?)),
Some(inner) => inner.poll(cx).map_err(Into::into),
None => Poll::Ready(Err(error::None::new().into())),
}
}