Skip to content

Commit

Permalink
Fix code lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaofei0800 committed Jan 17, 2025
1 parent 521ff7e commit 1a165ee
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/congestion_control/bbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/congestion_control/bbr3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/congestion_control/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/connection/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion src/connection/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/h3/h3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl<'a> HeaderRef<'a> {
}
}

impl<'a> NameValue for HeaderRef<'a> {
impl NameValue for HeaderRef<'_> {
fn name(&self) -> &[u8] {
self.0
}
Expand Down
2 changes: 1 addition & 1 deletion src/h3/qpack/huffman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
10 changes: 5 additions & 5 deletions src/ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>;

fn next(&mut self) -> Option<Range<u64>> {
Expand All @@ -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<Range<u64>> {
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()
}
Expand All @@ -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<u64> {
Expand All @@ -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<u64> {
if self.next == self.end {
let (&start, &end) = self.set.next_back()?;
Expand Down

0 comments on commit 1a165ee

Please sign in to comment.