From f70c17660af6ebe688d0570d2e795b86aa2056b8 Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Wed, 11 Jun 2025 07:43:20 +0000 Subject: [PATCH] runtime-rs: Fix clippy `unnecessary_map_or` Fix `unnecessary_map_or` clippy warning as suggested by rust 1.85.1. error: this `map_or` can be simplified --> crates/hypervisor/src/ch/inner_hypervisor.rs:1054:24 | 1054 | let have_tdx = fs::read(TDX_KVM_PARAMETER_PATH) | ________________________^ 1055 | | .map_or(false, |content| !content.is_empty() && content[0] == b'Y'); | |_______________________________________________________________________________^ help: use is_ok_and instead: `fs::read(TDX_KVM_PARAMETER_PATH).is_ok_and(|content| !content.is_empty() && content[0] == b'Y')` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or = note: `-D clippy::unnecessary-map-or` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_map_or)]` Signed-off-by: Ruoqing He --- src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs b/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs index 954ce30343..353b2f7978 100644 --- a/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs +++ b/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs @@ -1052,7 +1052,7 @@ mod tests { set_fake_guest_protection(None); let have_tdx = fs::read(TDX_KVM_PARAMETER_PATH) - .map_or(false, |content| !content.is_empty() && content[0] == b'Y'); + .is_ok_and(|content| !content.is_empty() && content[0] == b'Y'); let protection = task::spawn_blocking(|| -> Result { get_guest_protection() })