From 7cc433f50f1a33f8e27c693260e8aada93f9d711 Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 31 Mar 2025 13:54:38 +0800 Subject: [PATCH] clippy: Fix clippy::unnecessary_map_or Fix `clippy::unnecessary_map_or` warnings reported by clippy 0.1.85 (4d91de4e48 2025-02-17). ```console error: this `map_or` can be simplified --> vhost-device-scsi/src/virtio.rs:182:15 | 182 | while self | _______________^ 183 | | .current 184 | | .map_or(false, |current| self.offset >= current.len()) | |__________________________________________________________________^ | = 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)]` help: use is_some_and instead | 182 ~ while self 183 + .current.is_some_and(|current| self.offset >= current.len()) | ``` Signed-off-by: Ruoqing He --- vhost-device-scsi/src/virtio.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vhost-device-scsi/src/virtio.rs b/vhost-device-scsi/src/virtio.rs index 423c0ab..e585ee8 100644 --- a/vhost-device-scsi/src/virtio.rs +++ b/vhost-device-scsi/src/virtio.rs @@ -181,7 +181,7 @@ where self.add_written(bytes); while self .current - .map_or(false, |current| self.offset >= current.len()) + .is_some_and(|current| self.offset >= current.len()) { let current = self.current.expect("loop condition ensures existance"); self.offset -= current.len();