[pve-devel] [PATCH installer 1/2] tui: fix clippy warnings

Christoph Heiss c.heiss at proxmox.com
Mon Jul 10 15:26:25 CEST 2023


Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 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 68207c8..e8ee7f3 100644
--- a/proxmox-tui-installer/src/setup.rs
+++ b/proxmox-tui-installer/src/setup.rs
@@ -206,23 +206,19 @@ impl From<InstallerOptions> 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<T> {
 }
 
 impl<T: View> MultiDiskOptionsView<T> {
-    fn new(avail_disks: &[Disk], selected_disks: &Vec<usize>, 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<T: View> MultiDiskOptionsView<T> {
         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.41.0






More information about the pve-devel mailing list