mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: Replace map_or on false with is_some_and
Replace `map_or()` on false condition with `is_some_and` to provide better readability, as suggestted by v1.84.0-beta.1 `cargo clippy`. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
@@ -489,8 +489,7 @@ impl EpollHelperHandler for BlockEpollHandler {
|
||||
EpollHelperError::HandleEvent(anyhow!("Failed to get queue event: {:?}", e))
|
||||
})?;
|
||||
|
||||
let rate_limit_reached =
|
||||
self.rate_limiter.as_ref().map_or(false, |r| r.is_blocked());
|
||||
let rate_limit_reached = self.rate_limiter.as_ref().is_some_and(|r| r.is_blocked());
|
||||
|
||||
// Process the queue only when the rate limit is not reached
|
||||
if !rate_limit_reached {
|
||||
@@ -509,8 +508,7 @@ impl EpollHelperHandler for BlockEpollHandler {
|
||||
))
|
||||
})?;
|
||||
|
||||
let rate_limit_reached =
|
||||
self.rate_limiter.as_ref().map_or(false, |r| r.is_blocked());
|
||||
let rate_limit_reached = self.rate_limiter.as_ref().is_some_and(|r| r.is_blocked());
|
||||
|
||||
// Process the queue only when the rate limit is not reached
|
||||
if !rate_limit_reached {
|
||||
|
||||
@@ -201,7 +201,7 @@ impl NetEpollHandler {
|
||||
.net
|
||||
.rx_rate_limiter
|
||||
.as_ref()
|
||||
.map_or(false, |r| r.is_blocked());
|
||||
.is_some_and(|r| r.is_blocked());
|
||||
|
||||
// Start to listen on RX_TAP_EVENT only when the rate limit is not reached
|
||||
if !self.net.rx_tap_listening && !rate_limit_reached {
|
||||
@@ -238,7 +238,7 @@ impl NetEpollHandler {
|
||||
.net
|
||||
.tx_rate_limiter
|
||||
.as_ref()
|
||||
.map_or(false, |r| r.is_blocked());
|
||||
.is_some_and(|r| r.is_blocked());
|
||||
|
||||
if !rate_limit_reached {
|
||||
self.process_tx()?;
|
||||
|
||||
Reference in New Issue
Block a user