From 9e5cf6b6e954237fa654067df316da905c76a97f Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Mon, 10 Jul 2023 15:26:25 +0200 Subject: [PATCH] tui: fix clippy warnings Signed-off-by: Christoph Heiss --- proxmox-tui-installer/src/options.rs | 6 +----- proxmox-tui-installer/src/setup.rs | 8 ++------ proxmox-tui-installer/src/views/bootdisk.rs | 4 ++-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/proxmox-tui-installer/src/options.rs b/proxmox-tui-installer/src/options.rs index 62804c2..c8e8215 100644 --- a/proxmox-tui-installer/src/options.rs +++ b/proxmox-tui-installer/src/options.rs @@ -57,11 +57,7 @@ pub enum FsType { impl FsType { pub fn is_btrfs(&self) -> bool { - use FsType::Btrfs; - match self { - Btrfs(_) => true, - _ => false, - } + matches!(self, FsType::Btrfs(_)) } } diff --git a/proxmox-tui-installer/src/setup.rs b/proxmox-tui-installer/src/setup.rs index 9d14cf8..8c64c65 100644 --- a/proxmox-tui-installer/src/setup.rs +++ b/proxmox-tui-installer/src/setup.rs @@ -206,23 +206,19 @@ impl From for InstallConfig { config.hdsize = zfs.disk_size; config.zfs_opts = Some(zfs.clone().into()); - let mut i = 0; - for disk in &options.bootdisk.disks { + for (i, disk) in options.bootdisk.disks.iter().enumerate() { config .disk_selection .insert(i.to_string(), disk.index.clone()); - i = i + 1; } } AdvancedBootdiskOptions::Btrfs(btrfs) => { config.hdsize = btrfs.disk_size; - let mut i = 0; - for disk in &options.bootdisk.disks { + for (i, disk) in options.bootdisk.disks.iter().enumerate() { config .disk_selection .insert(i.to_string(), disk.index.clone()); - i = i + 1; } } } diff --git a/proxmox-tui-installer/src/views/bootdisk.rs b/proxmox-tui-installer/src/views/bootdisk.rs index 602e1da..4970655 100644 --- a/proxmox-tui-installer/src/views/bootdisk.rs +++ b/proxmox-tui-installer/src/views/bootdisk.rs @@ -274,7 +274,7 @@ struct MultiDiskOptionsView { } impl MultiDiskOptionsView { - fn new(avail_disks: &[Disk], selected_disks: &Vec, options_view: T) -> Self { + fn new(avail_disks: &[Disk], selected_disks: &[usize], options_view: T) -> Self { let mut selectable_disks = avail_disks .iter() .map(|d| (d.to_string(), Some(d.clone()))) @@ -283,7 +283,7 @@ impl MultiDiskOptionsView { selectable_disks.push(("-- do not use --".to_owned(), None)); let mut disk_form = FormView::new(); - for i in 0..avail_disks.len() { + for (i, _) in avail_disks.iter().enumerate() { disk_form.add_child( &format!("Harddisk {i}"), SelectView::new() -- 2.39.5