diff --git a/ntex-router/src/resource.rs b/ntex-router/src/resource.rs index 54b7ec84..c9097619 100644 --- a/ntex-router/src/resource.rs +++ b/ntex-router/src/resource.rs @@ -247,7 +247,7 @@ impl ResourceDef { let mut end = None; let mut tail = false; let mut rem = pattern; - let start = if pattern.starts_with('/') { 1 } else { 0 }; + let start = usize::from(pattern.starts_with('/')); let mut pattern = &pattern[start..]; elems.push(PathElement::Str('/'.to_string())); @@ -345,7 +345,7 @@ impl ResourceDef { } loop { - let start = if pattern.starts_with('/') { 1 } else { 0 }; + let start = usize::from(pattern.starts_with('/')); let idx = if let Some(idx) = pattern[start..].find(|c| c == '{' || c == '/') { idx + start } else { diff --git a/ntex-router/src/router.rs b/ntex-router/src/router.rs index 297729bd..f0e98a3f 100644 --- a/ntex-router/src/router.rs +++ b/ntex-router/src/router.rs @@ -2,7 +2,7 @@ use super::tree::Tree; use super::{IntoPattern, Resource, ResourceDef, ResourcePath}; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct ResourceId(pub(crate) u16); +pub struct ResourceId(u16); /// Resource router. #[derive(Clone)] diff --git a/ntex-tls/src/openssl/mod.rs b/ntex-tls/src/openssl/mod.rs index 2b6311d4..25d3a33c 100644 --- a/ntex-tls/src/openssl/mod.rs +++ b/ntex-tls/src/openssl/mod.rs @@ -177,7 +177,7 @@ impl Filter for SslFilter { }; let (hw, lw) = self.pool.read_params().unpack(); - let mut new_bytes = if self.handshake.get() { 1 } else { 0 }; + let mut new_bytes = usize::from(self.handshake.get()); loop { // make sure we've got room let remaining = dst.remaining_mut(); diff --git a/ntex-tls/src/rustls/client.rs b/ntex-tls/src/rustls/client.rs index 4ed5f444..c4c02b9d 100644 --- a/ntex-tls/src/rustls/client.rs +++ b/ntex-tls/src/rustls/client.rs @@ -110,7 +110,7 @@ impl Filter for TlsClientFilter { return Ok((0, 0)); }; - let mut new_bytes = if self.inner.handshake.get() { 1 } else { 0 }; + let mut new_bytes = usize::from(self.inner.handshake.get()); loop { // make sure we've got room let remaining = dst.remaining_mut(); diff --git a/ntex-tls/src/rustls/server.rs b/ntex-tls/src/rustls/server.rs index 6a22db15..e8dff213 100644 --- a/ntex-tls/src/rustls/server.rs +++ b/ntex-tls/src/rustls/server.rs @@ -110,7 +110,7 @@ impl Filter for TlsServerFilter { return Ok((0, 0)); }; - let mut new_bytes = if self.inner.handshake.get() { 1 } else { 0 }; + let mut new_bytes = usize::from(self.inner.handshake.get()); loop { // make sure we've got room let remaining = dst.remaining_mut(); diff --git a/ntex-tokio/src/io.rs b/ntex-tokio/src/io.rs index c0dc199e..54844d93 100644 --- a/ntex-tokio/src/io.rs +++ b/ntex-tokio/src/io.rs @@ -438,11 +438,11 @@ impl AsyncWrite for TokioIoBoxed { } fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - (*self.as_ref()).0.poll_flush(cx, false) + self.as_ref().0.poll_flush(cx, false) } fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - (*self.as_ref()).0.poll_shutdown(cx) + self.as_ref().0.poll_shutdown(cx) } } diff --git a/ntex-util/src/time/wheel.rs b/ntex-util/src/time/wheel.rs index f7007b16..c7949f30 100644 --- a/ntex-util/src/time/wheel.rs +++ b/ntex-util/src/time/wheel.rs @@ -403,9 +403,8 @@ impl Timer { } } - let adj = if lvl_clk == 0 { 0 } else { 1 }; clk >>= LVL_CLK_SHIFT; - clk += adj; + clk += u64::from(lvl_clk != 0); } if next < u64::MAX { diff --git a/ntex/src/http/request.rs b/ntex/src/http/request.rs index 63f19fb4..03406852 100644 --- a/ntex/src/http/request.rs +++ b/ntex/src/http/request.rs @@ -63,14 +63,14 @@ impl Request { #[inline] /// Http message part of the request pub fn head(&self) -> &RequestHead { - &*self.head + &self.head } #[inline] #[doc(hidden)] /// Mutable reference to a http message part of the request pub fn head_mut(&mut self) -> &mut RequestHead { - &mut *self.head + &mut self.head } /// Request's uri. diff --git a/ntex/src/http/response.rs b/ntex/src/http/response.rs index 8ff5fa3e..ce33f061 100644 --- a/ntex/src/http/response.rs +++ b/ntex/src/http/response.rs @@ -67,13 +67,13 @@ impl Response { #[inline] /// Http message part of the response pub fn head(&self) -> &ResponseHead { - &*self.head + &self.head } #[inline] /// Mutable reference to a http message part of the response pub fn head_mut(&mut self) -> &mut ResponseHead { - &mut *self.head + &mut self.head } /// Get the response status code diff --git a/ntex/src/server/config.rs b/ntex/src/server/config.rs index 552ad788..88668759 100644 --- a/ntex/src/server/config.rs +++ b/ntex/src/server/config.rs @@ -15,7 +15,7 @@ use super::Token; use super::{builder::bind_addr, counter::CounterGuard}; #[derive(Clone)] -pub struct Config(pub(super) Rc); +pub struct Config(Rc); pub(super) struct InnerServiceConfig { pub(super) pool: Cell, @@ -37,6 +37,10 @@ impl Config { self.0.pool.set(id); self } + + pub(super) fn get_pool_id(&self) -> PoolId { + self.0.pool.get() + } } pub struct ServiceConfig(pub(super) Rc>); diff --git a/ntex/src/server/service.rs b/ntex/src/server/service.rs index 2fd53c5d..ee4893d6 100644 --- a/ntex/src/server/service.rs +++ b/ntex/src/server/service.rs @@ -164,7 +164,7 @@ where match fut.await { Ok(inner) => { let service: BoxedServerService = - Box::new(StreamService::new(inner, cfg.0.pool.get())); + Box::new(StreamService::new(inner, cfg.get_pool_id())); Ok(vec![(token, service)]) } Err(_) => Err(()), diff --git a/ntex/src/web/httprequest.rs b/ntex/src/web/httprequest.rs index b6dfb23e..135bcbd6 100644 --- a/ntex/src/web/httprequest.rs +++ b/ntex/src/web/httprequest.rs @@ -192,7 +192,7 @@ impl HttpRequest { name: &str, ) -> Result { const NO_PARAMS: [&str; 0] = []; - self.url_for(name, &NO_PARAMS) + self.url_for(name, NO_PARAMS) } #[inline] diff --git a/ntex/src/ws/client.rs b/ntex/src/ws/client.rs index 01640f08..e5d51cb6 100644 --- a/ntex/src/ws/client.rs +++ b/ntex/src/ws/client.rs @@ -148,7 +148,7 @@ where // when decoded, is 16 bytes in length (RFC 6455) let mut sec_key: [u8; 16] = [0; 16]; WyRand::new().fill(&mut sec_key); - let key = base64::encode(&sec_key); + let key = base64::encode(sec_key); headers.insert( header::SEC_WEBSOCKET_KEY,