diff --git a/src/connmgr/client.rs b/src/connmgr/client.rs index 667c02ea..093be72f 100644 --- a/src/connmgr/client.rs +++ b/src/connmgr/client.rs @@ -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); diff --git a/src/connmgr/connection.rs b/src/connmgr/connection.rs index 3209f7d5..8f344592 100644 --- a/src/connmgr/connection.rs +++ b/src/connmgr/connection.rs @@ -527,7 +527,7 @@ pub struct AddrRef<'a> { s: Ref<'a, Option>>, } -impl<'a> AddrRef<'a> { +impl AddrRef<'_> { pub fn get(&self) -> Option<&[u8]> { match &*self.s { Some(s) => Some(s.as_slice()), @@ -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 + AsMut<[u8]>> Future + for SendMessageContentFuture<'_, '_, W, M> { type Output = Result<(usize, bool), Error>; @@ -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()), diff --git a/src/connmgr/server.rs b/src/connmgr/server.rs index a86466ce..180f2cc0 100644 --- a/src/connmgr/server.rs +++ b/src/connmgr/server.rs @@ -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); diff --git a/src/connmgr/tls.rs b/src/connmgr/tls.rs index 12be3594..84d50869 100644 --- a/src/connmgr/tls.rs +++ b/src/connmgr/tls.rs @@ -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(); diff --git a/src/connmgr/track.rs b/src/connmgr/track.rs index e2e6db2a..edebbf8d 100644 --- a/src/connmgr/track.rs +++ b/src/connmgr/track.rs @@ -70,7 +70,7 @@ impl<'a, A, B> Track<'a, (A, B)> { } } -impl<'a, T> Drop for Track<'a, T> { +impl Drop for Track<'_, T> { fn drop(&mut self) { if let Some(inner) = &self.inner { inner.active.set(false); @@ -78,7 +78,7 @@ impl<'a, T> Drop for Track<'a, T> { } } -impl<'a, T> Deref for Track<'a, T> { +impl Deref for Track<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -134,7 +134,7 @@ pub struct TrackFuture<'a, F> { value_active: &'a TrackFlag, } -impl<'a, F, T, E> Future for TrackFuture<'a, F> +impl Future for TrackFuture<'_, F> where F: Future>, E: From, diff --git a/src/core/http1/client.rs b/src/core/http1/client.rs index ff1a56bb..8bf8592b 100644 --- a/src/core/http1/client.rs +++ b/src/core/http1/client.rs @@ -647,7 +647,7 @@ pub struct FinishedKeepHeader<'a> { wbuf: &'a mut VecRingBuffer, } -impl<'a> FinishedKeepHeader<'a> { +impl FinishedKeepHeader<'_> { pub fn discard_header(self, resp: protocol::OwnedResponse) -> Finished { self.wbuf.set_inner(resp.into_buf()); self.wbuf.clear(); diff --git a/src/core/http1/protocol.rs b/src/core/http1/protocol.rs index e70f3c57..18f53ce0 100644 --- a/src/core/http1/protocol.rs +++ b/src/core/http1/protocol.rs @@ -605,7 +605,7 @@ pub struct OwnedRequest<'s, const N: usize> { expect_100: bool, } -impl<'s, const N: usize> OwnedRequest<'s, N> { +impl OwnedRequest<'_, N> { pub fn get(&self) -> Request { let req = self.req.get(); @@ -640,7 +640,7 @@ pub struct OwnedResponse<'s, const N: usize> { body_size: BodySize, } -impl<'s, const N: usize> OwnedResponse<'s, N> { +impl OwnedResponse<'_, N> { pub fn get(&self) -> Response { let resp = self.resp.get(); diff --git a/src/core/http1/server.rs b/src/core/http1/server.rs index 2d149d63..e65e3785 100644 --- a/src/core/http1/server.rs +++ b/src/core/http1/server.rs @@ -469,7 +469,7 @@ pub struct ResponseState<'a, R: AsyncRead, W: AsyncWrite> { inner: RefCell>>, } -impl<'a, R: AsyncRead, W: AsyncWrite> Default for ResponseState<'a, R, W> { +impl Default for ResponseState<'_, R, W> { fn default() -> Self { Self { inner: RefCell::new(None), @@ -517,7 +517,7 @@ pub struct ResponsePrepareBody<'a, 'b, R: AsyncRead, W: AsyncWrite> { state: &'b RefCell>>, } -impl<'a, 'b, R: AsyncRead, W: AsyncWrite> ResponsePrepareBody<'a, 'b, R, W> { +impl 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(); diff --git a/src/core/io.rs b/src/core/io.rs index 073c8252..a74b9eba 100644 --- a/src/core/io.rs +++ b/src/core/io.rs @@ -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 Write for StdWriteWrapper<'_, '_, W> { fn write(&mut self, buf: &[u8]) -> Result { match self.w.as_mut().poll_write(self.cx, buf) { Poll::Ready(ret) => ret, @@ -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 Future for ReadFuture<'_, R> { type Output = Result; fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { @@ -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 Drop for ReadFuture<'_, R> { fn drop(&mut self) { self.r.cancel(); } @@ -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 Future for WriteFuture<'_, W> { type Output = Result; fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { @@ -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 Drop for WriteFuture<'_, W> { fn drop(&mut self) { self.w.cancel(); } @@ -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 Future for CloseFuture<'_, W> { type Output = Result<(), io::Error>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { @@ -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 Drop for CloseFuture<'_, W> { fn drop(&mut self) { self.w.cancel(); } @@ -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 Future for WriteVectoredFuture<'_, W> { type Output = Result; fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { @@ -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 Drop for WriteVectoredFuture<'_, W> { fn drop(&mut self) { self.w.cancel(); } @@ -391,7 +391,7 @@ pub struct WriteSharedFuture<'a, W: AsyncWrite + ?Sized + Unpin, B: AsRef<[u8]>> buf: &'a RefCell, } -impl<'a, W: AsyncWrite + ?Sized, B: AsRef<[u8]>> Future for WriteSharedFuture<'a, W, B> { +impl> Future for WriteSharedFuture<'_, W, B> { type Output = Result; fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { @@ -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> Drop for WriteSharedFuture<'_, W, B> { fn drop(&mut self) { self.w.cancel(); } diff --git a/src/core/reactor.rs b/src/core/reactor.rs index 1a0f2309..68cc3b4b 100644 --- a/src/core/reactor.rs +++ b/src/core/reactor.rs @@ -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 {