[PATCH proxmox v2 09/25] disks: clippy: collapse if-let chains where possible

Lukas Wagner
2026-03-19T09:46:41Z

proxmox-disks/src/lib.rs | 21 ++++++++++-----------
proxmox-disks/src/lvm.rs | 10 +++++-----
proxmox-disks/src/smart.rs | 8 ++++----
proxmox-disks/src/zfs.rs | 10 +++++-----
4 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/proxmox-disks/src/lib.rs b/proxmox-disks/src/lib.rs
index 74907711..41e95b40 100644
--- a/proxmox-disks/src/lib.rs
+++ b/proxmox-disks/src/lib.rs
@@ -1009,21 +1009,20 @@ fn get_disks(

let name = item.file_name().to_str().unwrap().to_string();

- if let Some(ref disks) = disks {
- if !disks.contains(&name) {
- continue;
- }
+ if let Some(ref disks) = disks
+ && !disks.contains(&name)
+ {
+ continue;
}

let sys_path = format!("/sys/block/{name}");

- if let Ok(target) = std::fs::read_link(&sys_path) {
- if let Some(target) = target.to_str() {
- if ISCSI_PATH_REGEX.is_match(target) {
- continue;
- } // skip iSCSI devices
- }
- }
+ if let Ok(target) = std::fs::read_link(&sys_path)
+ && let Some(target) = target.to_str()
+ && ISCSI_PATH_REGEX.is_match(target)
+ {
+ continue;
+ } // skip iSCSI devices

let disk = disk_manager.clone().disk_by_sys_path(&sys_path)?;

diff --git a/proxmox-disks/src/lvm.rs b/proxmox-disks/src/lvm.rs
index 1456a21c..4c1ed4a4 100644
--- a/proxmox-disks/src/lvm.rs
+++ b/proxmox-disks/src/lvm.rs
@@ -34,11 +34,11 @@ pub fn get_lvm_devices(lsblk_info: &[LsblkInfo]) -> Result<HashSet<u64>, Error>
let mut device_set: HashSet<u64> = HashSet::new();

for info in lsblk_info.iter() {
- if let Some(partition_type) = &info.partition_type {
- if LVM_UUIDS.contains(partition_type.as_str()) {
- let meta = std::fs::metadata(&info.path)?;
- device_set.insert(meta.rdev());
- }
+ if let Some(partition_type) = &info.partition_type
+ && LVM_UUIDS.contains(partition_type.as_str())
+ {
+ let meta = std::fs::metadata(&info.path)?;
+ device_set.insert(meta.rdev());
}
}

diff --git a/proxmox-disks/src/smart.rs b/proxmox-disks/src/smart.rs
index 247bc4d3..e27348a6 100644
--- a/proxmox-disks/src/smart.rs
+++ b/proxmox-disks/src/smart.rs
@@ -174,10 +174,10 @@ pub fn get_smart_data(disk_path: &Path, health_only: bool) -> Result<SmartData,
for (name, value) in list {
if name == "percentage_used" {
// extract wearout from nvme text, allow for decimal values
- if let Some(v) = value.as_f64() {
- if v <= 100.0 {
- wearout = Some(100.0 - v);
- }
+ if let Some(v) = value.as_f64()
+ && v <= 100.0
+ {
+ wearout = Some(100.0 - v);
}
}
if let Some(value) = value.as_f64() {
diff --git a/proxmox-disks/src/zfs.rs b/proxmox-disks/src/zfs.rs
index 0babb887..874224a7 100644
--- a/proxmox-disks/src/zfs.rs
+++ b/proxmox-disks/src/zfs.rs
@@ -81,11 +81,11 @@ pub fn zfs_devices(lsblk_info: &[LsblkInfo], pool: Option<String>) -> Result<Has
}
if pool.is_none() {
for info in lsblk_info.iter() {
- if let Some(partition_type) = &info.partition_type {
- if ZFS_UUIDS.contains(partition_type.as_str()) {
- let meta = std::fs::metadata(&info.path)?;
- device_set.insert(meta.rdev());
- }
+ if let Some(partition_type) = &info.partition_type
+ && ZFS_UUIDS.contains(partition_type.as_str())
+ {
+ let meta = std::fs::metadata(&info.path)?;
+ device_set.insert(meta.rdev());
}
}
}
--
2.47.3