diff --git a/src/congestion_control/bbr.rs b/src/congestion_control/bbr.rs index 0dcb4bf7..ea8262c8 100644 --- a/src/congestion_control/bbr.rs +++ b/src/congestion_control/bbr.rs @@ -1064,7 +1064,7 @@ impl CongestionController for Bbr { } fn in_recovery(&self, sent_time: Instant) -> bool { - self.recovery_epoch_start.map_or(false, |t| sent_time <= t) + self.recovery_epoch_start.is_some_and(|t| sent_time <= t) } fn in_slow_start(&self) -> bool { diff --git a/src/congestion_control/bbr3.rs b/src/congestion_control/bbr3.rs index 53830c90..e9e66c30 100644 --- a/src/congestion_control/bbr3.rs +++ b/src/congestion_control/bbr3.rs @@ -760,7 +760,7 @@ impl Bbr3 { } fn in_recovery(&self, sent_time: Instant) -> bool { - self.recovery_epoch_start.map_or(false, |t| sent_time <= t) + self.recovery_epoch_start.is_some_and(|t| sent_time <= t) } fn in_slow_start(&self) -> bool { diff --git a/src/congestion_control/cubic.rs b/src/congestion_control/cubic.rs index f65225e8..4e5622f2 100644 --- a/src/congestion_control/cubic.rs +++ b/src/congestion_control/cubic.rs @@ -506,7 +506,7 @@ impl CongestionController for Cubic { } fn in_recovery(&self, sent_time: Instant) -> bool { - self.recovery_epoch_start.map_or(false, |t| sent_time <= t) + self.recovery_epoch_start.is_some_and(|t| sent_time <= t) } fn congestion_window(&self) -> u64 { diff --git a/src/connection/connection.rs b/src/connection/connection.rs index cff570e7..e00adb5c 100644 --- a/src/connection/connection.rs +++ b/src/connection/connection.rs @@ -2996,7 +2996,7 @@ impl Connection { // frame in a packet with the highest level of packet protection to // avoid the packet being discarded. // See RFC 9000 Section 10.2.3 - if self.local_error.as_ref().map_or(false, |e| !e.is_app) { + if self.local_error.as_ref().is_some_and(|e| !e.is_app) { let pkt_type = match self.tls_session.write_level() { Level::Initial => PacketType::Initial, Level::Handshake => PacketType::Handshake, @@ -3073,7 +3073,7 @@ impl Connection { || self.tls_session.is_in_early_data()) && (self.need_send_handshake_done_frame() || self.need_send_new_token_frame() - || self.local_error.as_ref().map_or(false, |e| e.is_app) + || self.local_error.as_ref().is_some_and(|e| e.is_app) || path.need_send_validation_frames(self.is_server) || path.dplpmtud.should_probe() || path.need_send_ping @@ -3094,7 +3094,7 @@ impl Connection { fn need_send_path_unaware_frames(&self) -> bool { self.need_send_handshake_done_frame() || self.need_send_new_token_frame() - || self.local_error.as_ref().map_or(false, |e| e.is_app) + || self.local_error.as_ref().is_some_and(|e| e.is_app) || self.cids.need_send_cid_control_frames() || self.streams.need_send_stream_frames() } diff --git a/src/connection/timer.rs b/src/connection/timer.rs index 8334bbac..8169e1ff 100644 --- a/src/connection/timer.rs +++ b/src/connection/timer.rs @@ -77,7 +77,7 @@ impl TimerTable { /// Check whether the given timer is expired pub fn is_expired(&self, timer: Timer, after: Instant) -> bool { - self.expires[timer as usize].map_or(false, |x| x <= after) + self.expires[timer as usize].is_some_and(|x| x <= after) } } diff --git a/src/endpoint.rs b/src/endpoint.rs index 1dc5035e..3d0919e6 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -757,10 +757,7 @@ impl Endpoint { &self.trace_id, ); - let done = match self.sender.on_packets_send(batch) { - Ok(v) => v, - Err(e) => return Err(e), - }; + let done = self.sender.on_packets_send(batch)?; if done == 0 { break; } diff --git a/src/h3/h3.rs b/src/h3/h3.rs index f977cd89..7313e57b 100644 --- a/src/h3/h3.rs +++ b/src/h3/h3.rs @@ -175,7 +175,7 @@ impl<'a> HeaderRef<'a> { } } -impl<'a> NameValue for HeaderRef<'a> { +impl NameValue for HeaderRef<'_> { fn name(&self) -> &[u8] { self.0 } diff --git a/src/h3/qpack/huffman.rs b/src/h3/qpack/huffman.rs index 5e27e6fd..9439b1da 100644 --- a/src/h3/qpack/huffman.rs +++ b/src/h3/qpack/huffman.rs @@ -419,7 +419,7 @@ const ENCODE_TABLE: [(usize, u64); 257] = [ ]; /// The multi-level decoding table for huffman decoder. -const DECODE_TABLE: [[(usize, u8, u8); 16]; 256] = [ +static DECODE_TABLE: [[(usize, u8, u8); 16]; 256] = [ // 0 [ // (next-state, byte, flags). diff --git a/src/ranges.rs b/src/ranges.rs index b03a6de2..4f1ebfc9 100644 --- a/src/ranges.rs +++ b/src/ranges.rs @@ -307,7 +307,7 @@ pub struct Iter<'a> { set: btree_map::Iter<'a, u64, u64>, } -impl<'a> Iterator for Iter<'a> { +impl Iterator for Iter<'_> { type Item = Range; fn next(&mut self) -> Option> { @@ -316,14 +316,14 @@ impl<'a> Iterator for Iter<'a> { } } -impl<'a> DoubleEndedIterator for Iter<'a> { +impl DoubleEndedIterator for Iter<'_> { fn next_back(&mut self) -> Option> { let (&start, &end) = self.set.next_back()?; Some(start..end) } } -impl<'a> ExactSizeIterator for Iter<'a> { +impl ExactSizeIterator for Iter<'_> { fn len(&self) -> usize { self.set.len() } @@ -335,7 +335,7 @@ pub struct Flatten<'a> { end: u64, } -impl<'a> Iterator for Flatten<'a> { +impl Iterator for Flatten<'_> { type Item = u64; fn next(&mut self) -> Option { @@ -353,7 +353,7 @@ impl<'a> Iterator for Flatten<'a> { } } -impl<'a> DoubleEndedIterator for Flatten<'a> { +impl DoubleEndedIterator for Flatten<'_> { fn next_back(&mut self) -> Option { if self.next == self.end { let (&start, &end) = self.set.next_back()?;