Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges committed Jan 7, 2025
1 parent b371f91 commit c6c4a83
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/connmgr/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ impl Worker {

let instance_id = Rc::new(instance_id);

let ka_batch = (stream_maxconn + (KEEP_ALIVE_BATCHES - 1)) / KEEP_ALIVE_BATCHES;
let ka_batch = stream_maxconn.div_ceil(KEEP_ALIVE_BATCHES);

let batch = Batch::new(ka_batch);

Expand Down
8 changes: 4 additions & 4 deletions src/connmgr/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ pub struct AddrRef<'a> {
s: Ref<'a, Option<ArrayVec<u8, 64>>>,
}

impl<'a> AddrRef<'a> {
impl AddrRef<'_> {
pub fn get(&self) -> Option<&[u8]> {
match &*self.s {
Some(s) => Some(s.as_slice()),
Expand Down Expand Up @@ -701,8 +701,8 @@ struct SendMessageContentFuture<'a, 'b, W: AsyncWrite, M> {
done: bool,
}

impl<'a, 'b, W: AsyncWrite, M: AsRef<[u8]> + AsMut<[u8]>> Future
for SendMessageContentFuture<'a, 'b, W, M>
impl<W: AsyncWrite, M: AsRef<[u8]> + AsMut<[u8]>> Future
for SendMessageContentFuture<'_, '_, W, M>
{
type Output = Result<(usize, bool), Error>;

Expand Down Expand Up @@ -4210,7 +4210,7 @@ enum AsyncStream<'a> {
Tls(AsyncTlsStream<'a>),
}

impl<'a> AsyncStream<'a> {
impl AsyncStream<'_> {
fn into_inner(self) -> Stream {
match self {
Self::Plain(stream) => Stream::Plain(stream.into_std()),
Expand Down
2 changes: 1 addition & 1 deletion src/connmgr/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ impl Worker {

let instance_id = Rc::new(instance_id);

let ka_batch = (stream_maxconn + (KEEP_ALIVE_BATCHES - 1)) / KEEP_ALIVE_BATCHES;
let ka_batch = stream_maxconn.div_ceil(KEEP_ALIVE_BATCHES);

let batch = Batch::new(ka_batch);

Expand Down
2 changes: 1 addition & 1 deletion src/connmgr/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ impl<'a: 'b, 'b> AsyncTlsStream<'a> {
}
}

impl<'a> Drop for AsyncTlsStream<'a> {
impl Drop for AsyncTlsStream<'_> {
fn drop(&mut self) {
let registration = self.waker.take_registration();

Expand Down
6 changes: 3 additions & 3 deletions src/connmgr/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ impl<'a, A, B> Track<'a, (A, B)> {
}
}

impl<'a, T> Drop for Track<'a, T> {
impl<T> Drop for Track<'_, T> {
fn drop(&mut self) {
if let Some(inner) = &self.inner {
inner.active.set(false);
}
}
}

impl<'a, T> Deref for Track<'a, T> {
impl<T> Deref for Track<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand Down Expand Up @@ -134,7 +134,7 @@ pub struct TrackFuture<'a, F> {
value_active: &'a TrackFlag,
}

impl<'a, F, T, E> Future for TrackFuture<'a, F>
impl<F, T, E> Future for TrackFuture<'_, F>
where
F: Future<Output = Result<T, E>>,
E: From<ValueActiveError>,
Expand Down
2 changes: 1 addition & 1 deletion src/core/http1/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ pub struct FinishedKeepHeader<'a> {
wbuf: &'a mut VecRingBuffer,
}

impl<'a> FinishedKeepHeader<'a> {
impl FinishedKeepHeader<'_> {
pub fn discard_header<const N: usize>(self, resp: protocol::OwnedResponse<N>) -> Finished {
self.wbuf.set_inner(resp.into_buf());
self.wbuf.clear();
Expand Down
4 changes: 2 additions & 2 deletions src/core/http1/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ pub struct OwnedRequest<'s, const N: usize> {
expect_100: bool,
}

impl<'s, const N: usize> OwnedRequest<'s, N> {
impl<const N: usize> OwnedRequest<'_, N> {
pub fn get(&self) -> Request {
let req = self.req.get();

Expand Down Expand Up @@ -640,7 +640,7 @@ pub struct OwnedResponse<'s, const N: usize> {
body_size: BodySize,
}

impl<'s, const N: usize> OwnedResponse<'s, N> {
impl<const N: usize> OwnedResponse<'_, N> {
pub fn get(&self) -> Response {
let resp = self.resp.get();

Expand Down
4 changes: 2 additions & 2 deletions src/core/http1/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ pub struct ResponseState<'a, R: AsyncRead, W: AsyncWrite> {
inner: RefCell<Option<ResponseStateInner<'a, R, W>>>,
}

impl<'a, R: AsyncRead, W: AsyncWrite> Default for ResponseState<'a, R, W> {
impl<R: AsyncRead, W: AsyncWrite> Default for ResponseState<'_, R, W> {
fn default() -> Self {
Self {
inner: RefCell::new(None),
Expand Down Expand Up @@ -517,7 +517,7 @@ pub struct ResponsePrepareBody<'a, 'b, R: AsyncRead, W: AsyncWrite> {
state: &'b RefCell<Option<ResponseStateInner<'a, R, W>>>,
}

impl<'a, 'b, R: AsyncRead, W: AsyncWrite> ResponsePrepareBody<'a, 'b, R, W> {
impl<R: AsyncRead, W: AsyncWrite> ResponsePrepareBody<'_, '_, R, W> {
// only returns an error on invalid input
pub fn prepare(&mut self, src: &[u8], end: bool) -> Result<(usize, usize), Error> {
let state = self.state.borrow();
Expand Down
22 changes: 11 additions & 11 deletions src/core/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<'a, 'b, W: AsyncWrite> StdWriteWrapper<'a, 'b, W> {
}
}

impl<'a, 'b, W: AsyncWrite> Write for StdWriteWrapper<'a, 'b, W> {
impl<W: AsyncWrite> Write for StdWriteWrapper<'_, '_, W> {
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
match self.w.as_mut().poll_write(self.cx, buf) {
Poll::Ready(ret) => ret,
Expand Down Expand Up @@ -244,7 +244,7 @@ pub struct ReadFuture<'a, R: AsyncRead + ?Sized> {
buf: &'a mut [u8],
}

impl<'a, R: AsyncRead + ?Sized> Future for ReadFuture<'a, R> {
impl<R: AsyncRead + ?Sized> Future for ReadFuture<'_, R> {
type Output = Result<usize, io::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
Expand All @@ -256,7 +256,7 @@ impl<'a, R: AsyncRead + ?Sized> Future for ReadFuture<'a, R> {
}
}

impl<'a, R: AsyncRead + ?Sized> Drop for ReadFuture<'a, R> {
impl<R: AsyncRead + ?Sized> Drop for ReadFuture<'_, R> {
fn drop(&mut self) {
self.r.cancel();
}
Expand All @@ -268,7 +268,7 @@ pub struct WriteFuture<'a, W: AsyncWrite + ?Sized + Unpin> {
pos: usize,
}

impl<'a, W: AsyncWrite + ?Sized> Future for WriteFuture<'a, W> {
impl<W: AsyncWrite + ?Sized> Future for WriteFuture<'_, W> {
type Output = Result<usize, io::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
Expand All @@ -291,7 +291,7 @@ impl<'a, W: AsyncWrite + ?Sized> Future for WriteFuture<'a, W> {
}
}

impl<'a, W: AsyncWrite + ?Sized> Drop for WriteFuture<'a, W> {
impl<W: AsyncWrite + ?Sized> Drop for WriteFuture<'_, W> {
fn drop(&mut self) {
self.w.cancel();
}
Expand All @@ -301,7 +301,7 @@ pub struct CloseFuture<'a, W: AsyncWrite + ?Sized> {
w: &'a mut W,
}

impl<'a, W: AsyncWrite + ?Sized> Future for CloseFuture<'a, W> {
impl<W: AsyncWrite + ?Sized> Future for CloseFuture<'_, W> {
type Output = Result<(), io::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
Expand All @@ -313,7 +313,7 @@ impl<'a, W: AsyncWrite + ?Sized> Future for CloseFuture<'a, W> {
}
}

impl<'a, W: AsyncWrite + ?Sized> Drop for CloseFuture<'a, W> {
impl<W: AsyncWrite + ?Sized> Drop for CloseFuture<'_, W> {
fn drop(&mut self) {
self.w.cancel();
}
Expand Down Expand Up @@ -341,7 +341,7 @@ pub struct WriteVectoredFuture<'a, W: AsyncWrite + ?Sized + Unpin> {
pos: usize,
}

impl<'a, W: AsyncWrite + ?Sized> Future for WriteVectoredFuture<'a, W> {
impl<W: AsyncWrite + ?Sized> Future for WriteVectoredFuture<'_, W> {
type Output = Result<usize, io::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
Expand Down Expand Up @@ -380,7 +380,7 @@ impl<'a, W: AsyncWrite + ?Sized> Future for WriteVectoredFuture<'a, W> {
}
}

impl<'a, W: AsyncWrite + ?Sized> Drop for WriteVectoredFuture<'a, W> {
impl<W: AsyncWrite + ?Sized> Drop for WriteVectoredFuture<'_, W> {
fn drop(&mut self) {
self.w.cancel();
}
Expand All @@ -391,7 +391,7 @@ pub struct WriteSharedFuture<'a, W: AsyncWrite + ?Sized + Unpin, B: AsRef<[u8]>>
buf: &'a RefCell<B>,
}

impl<'a, W: AsyncWrite + ?Sized, B: AsRef<[u8]>> Future for WriteSharedFuture<'a, W, B> {
impl<W: AsyncWrite + ?Sized, B: AsRef<[u8]>> Future for WriteSharedFuture<'_, W, B> {
type Output = Result<usize, io::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
Expand All @@ -403,7 +403,7 @@ impl<'a, W: AsyncWrite + ?Sized, B: AsRef<[u8]>> Future for WriteSharedFuture<'a
}
}

impl<'a, W: AsyncWrite + ?Sized, B: AsRef<[u8]>> Drop for WriteSharedFuture<'a, W, B> {
impl<W: AsyncWrite + ?Sized, B: AsRef<[u8]>> Drop for WriteSharedFuture<'_, W, B> {
fn drop(&mut self) {
self.w.cancel();
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/reactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn duration_to_ticks_round_down(d: Duration) -> u64 {
}

fn duration_to_ticks_round_up(d: Duration) -> u64 {
((d.as_millis() + (TICK_DURATION_MS as u128) - 1) / (TICK_DURATION_MS as u128)) as u64
d.as_millis().div_ceil(TICK_DURATION_MS as u128) as u64
}

fn ticks_to_duration(t: u64) -> Duration {
Expand Down

0 comments on commit c6c4a83

Please sign in to comment.