diff --git a/quinn-h3/src/proto/settings.rs b/quinn-h3/src/proto/settings.rs index e44b1ec97..e446364ac 100644 --- a/quinn-h3/src/proto/settings.rs +++ b/quinn-h3/src/proto/settings.rs @@ -21,12 +21,12 @@ impl SettingId { const NONE: SettingId = SettingId(0); fn is_supported(self) -> bool { - match self { + matches!( + self, SettingId::MAX_HEADER_LIST_SIZE - | SettingId::QPACK_MAX_TABLE_CAPACITY - | SettingId::QPACK_MAX_BLOCKED_STREAMS => true, - _ => false, - } + | SettingId::QPACK_MAX_TABLE_CAPACITY + | SettingId::QPACK_MAX_BLOCKED_STREAMS + ) } } diff --git a/quinn-h3/src/qpack/dynamic.rs b/quinn-h3/src/qpack/dynamic.rs index 3b39a7adc..e647a53c2 100644 --- a/quinn-h3/src/qpack/dynamic.rs +++ b/quinn-h3/src/qpack/dynamic.rs @@ -475,10 +475,7 @@ impl DynamicTable { } fn is_tracked(&self, reference: usize) -> bool { - match self.track_map.get(&reference) { - Some(count) if *count > 0 => true, - _ => false, - } + matches!(self.track_map.get(&reference), Some(count) if *count > 0) } fn track_block(&mut self, stream_id: u64, refs: HashMap) { diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index 3dbbc6e16..ebc076033 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -3079,34 +3079,19 @@ impl State { } fn is_handshake(&self) -> bool { - match *self { - State::Handshake(_) => true, - _ => false, - } + matches!(*self, State::Handshake(_)) } fn is_established(&self) -> bool { - match *self { - State::Established => true, - _ => false, - } + matches!(*self, State::Established) } fn is_closed(&self) -> bool { - match *self { - State::Closed(_) => true, - State::Draining => true, - State::Drained => true, - _ => false, - } + matches!(*self, State::Closed(_) | State::Draining | State::Drained) } fn is_drained(&self) -> bool { - if let State::Drained = *self { - true - } else { - false - } + matches!(*self, State::Drained) } } diff --git a/quinn-proto/src/connection/streams.rs b/quinn-proto/src/connection/streams.rs index 79b97a57d..481240591 100644 --- a/quinn-proto/src/connection/streams.rs +++ b/quinn-proto/src/connection/streams.rs @@ -1035,18 +1035,12 @@ impl Recv { } fn receiving_unknown_size(&self) -> bool { - match self.state { - RecvState::Recv { size: None } => true, - _ => false, - } + matches!(self.state, RecvState::Recv { size: None }) } /// No more data expected from peer fn is_finished(&self) -> bool { - match self.state { - RecvState::Recv { .. } => false, - _ => true, - } + !matches!(self.state, RecvState::Recv { .. }) } /// All data read by application diff --git a/quinn-proto/src/packet.rs b/quinn-proto/src/packet.rs index f0f9f4f8f..e9ff5af8e 100644 --- a/quinn-proto/src/packet.rs +++ b/quinn-proto/src/packet.rs @@ -54,11 +54,7 @@ impl PartialDecode { } pub(crate) fn has_long_header(&self) -> bool { - use self::PlainHeader::*; - match self.plain_header { - Short { .. } => false, - _ => true, - } + !matches!(self.plain_header, PlainHeader::Short { .. }) } pub(crate) fn is_initial(&self) -> bool { @@ -343,10 +339,7 @@ impl Header { /// Whether the packet is encrypted on the wire pub(crate) fn is_protected(&self) -> bool { - match *self { - Header::Retry { .. } | Header::VersionNegotiate { .. } => false, - _ => true, - } + !matches!(*self, Header::Retry { .. } | Header::VersionNegotiate { .. }) } pub(crate) fn number(&self) -> Option { @@ -385,10 +378,7 @@ impl Header { } pub(crate) fn is_short(&self) -> bool { - match *self { - Header::Short { .. } => true, - _ => false, - } + matches!(*self, Header::Short { .. }) } pub(crate) fn is_1rtt(&self) -> bool { @@ -396,13 +386,7 @@ impl Header { } pub(crate) fn is_0rtt(&self) -> bool { - match *self { - Header::Long { - ty: LongType::ZeroRtt, - .. - } => true, - _ => false, - } + matches!(*self, Header::Long { ty: LongType::ZeroRtt, .. }) } pub(crate) fn dst_cid(&self) -> &ConnectionId {