diff --git a/src/config.rs b/src/config.rs index 139da942..90e3958a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -679,10 +679,7 @@ impl ConfigType { /// Check if it is manager server type pub fn is_manager(self) -> bool { - match self { - ConfigType::Manager => true, - _ => false, - } + matches!(self, ConfigType::Manager) } } @@ -696,17 +693,11 @@ pub enum Mode { impl Mode { pub fn enable_udp(self) -> bool { - match self { - Mode::UdpOnly | Mode::TcpAndUdp => true, - _ => false, - } + matches!(self, Mode::UdpOnly | Mode::TcpAndUdp) } pub fn enable_tcp(self) -> bool { - match self { - Mode::TcpOnly | Mode::TcpAndUdp => true, - _ => false, - } + matches!(self, Mode::TcpOnly | Mode::TcpAndUdp) } } diff --git a/src/crypto/ring.rs b/src/crypto/ring.rs index 8662a4a4..3b38d154 100644 --- a/src/crypto/ring.rs +++ b/src/crypto/ring.rs @@ -119,10 +119,8 @@ impl<'a> AsMut<[u8]> for SealBuffer<'a> { impl<'a, 'in_out> Extend<&'in_out u8> for SealBuffer<'a> { fn extend>(&mut self, iter: T) { - let mut idx = 0; - for b in iter { + for (idx, b) in iter.into_iter().enumerate() { self.buffer[self.input_len + idx] = *b; - idx += 1; } } } diff --git a/src/relay/tcprelay/http_local.rs b/src/relay/tcprelay/http_local.rs index 58e02c0a..b3feb488 100644 --- a/src/relay/tcprelay/http_local.rs +++ b/src/relay/tcprelay/http_local.rs @@ -391,11 +391,8 @@ fn host_addr(uri: &Uri) -> Option
{ } fn check_keep_alive(version: Version, headers: &HeaderMap, check_proxy: bool) -> bool { - let mut conn_keep_alive = match version { - Version::HTTP_09 | Version::HTTP_10 => false, - // HTTP/1.1, HTTP/2, HTTP/3 keeps alive by default - _ => true, - }; + // HTTP/1.1, HTTP/2, HTTP/3 keeps alive by default + let mut conn_keep_alive = !matches!(version, Version::HTTP_09 | Version::HTTP_10); if check_proxy { // Modern browers will send Proxy-Connection instead of Connection diff --git a/src/relay/tcprelay/proxy_stream.rs b/src/relay/tcprelay/proxy_stream.rs index 56777c3a..55d845cd 100644 --- a/src/relay/tcprelay/proxy_stream.rs +++ b/src/relay/tcprelay/proxy_stream.rs @@ -180,10 +180,7 @@ enum ProxyConnection { impl ProxyConnection { /// Check if the underlying connection is proxied fn is_proxied(&self) -> bool { - match *self { - ProxyConnection::Proxied { .. } => true, - _ => false, - } + matches!(*self, ProxyConnection::Proxied { .. }) } fn local_addr(&self) -> io::Result {