]> git.proxmox.com Git - pve-installer.git/commitdiff
tui: bootdisk: refactor Rc<RefCell<..>> type into custom type
authorChristoph Heiss <c.heiss@proxmox.com>
Thu, 9 Nov 2023 09:40:55 +0000 (10:40 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 9 Nov 2023 13:47:03 +0000 (14:47 +0100)
Will be used/passed around quite a lot of times due to future changes,
so simplify it a bit.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-tui-installer/src/views/bootdisk.rs

index 52722587fdb6c2abaa91047a5929cd6be6b85b0d..6309d7450bed398384fa2486dafab4042ad50ce8 100644 (file)
@@ -29,9 +29,13 @@ use proxmox_installer_common::{
 /// https://openzfs.github.io/openzfs-docs/Performance%20and%20Tuning/Module%20Parameters.html#zfs-arc-max
 const ZFS_ARC_MIN_SIZE_MIB: usize = 64; // MiB
 
+/// Convience wrapper when needing to take a (interior-mutable) reference to `BootdiskOptions`.
+/// Interior mutability is safe for this case, as it is completely single-threaded.
+pub type BootdiskOptionsRef = Rc<RefCell<BootdiskOptions>>;
+
 pub struct BootdiskOptionsView {
     view: LinearLayout,
-    advanced_options: Rc<RefCell<BootdiskOptions>>,
+    advanced_options: BootdiskOptionsRef,
     boot_type: BootType,
 }
 
@@ -616,17 +620,17 @@ impl ViewWrapper for ZfsBootdiskOptionsView {
 
 fn advanced_options_view(
     runinfo: &RuntimeInfo,
-    options: Rc<RefCell<BootdiskOptions>>,
+    options_ref: BootdiskOptionsRef,
     product_conf: ProductConfig,
 ) -> impl View {
     Dialog::around(AdvancedBootdiskOptionsView::new(
         runinfo,
-        &(*options).borrow(),
+        &(*options_ref).borrow(),
         product_conf,
     ))
     .title("Advanced bootdisk options")
     .button("Ok", {
-        let options_ref = options.clone();
+        let options_ref = options_ref.clone();
         move |siv| {
             let options = siv
                 .call_on_name("advanced-bootdisk-options-dialog", |view: &mut Dialog| {