Improve readability through syntax sugar
ref tikv/tikv#13908
Nit: use lib API to improve readability
@@ -5028,13 +5028,12 @@ where
// ReadIndex can be processed on the replicas.
let is_read_index_request =
request.len() == 1 && request[0].get_cmd_type() == CmdType::ReadIndex;
- let mut read_only = true;
- for r in msg.get_requests() {
- match r.get_cmd_type() {
- CmdType::Get | CmdType::Snap | CmdType::ReadIndex => (),
- _ => read_only = false,
- }
- }
+ let read_only = msg.get_requests().iter().all(|r| {
+ matches!(
+ r.get_cmd_type(),
+ CmdType::Get | CmdType::Snap | CmdType::ReadIndex,
+ )
+ });
let region_id = self.region_id();
let allow_replica_read = read_only && msg.get_header().get_replica_read();
let flags = WriteBatchFlags::from_bits_check(msg.get_header().get_flags());
