all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer v2 1/3] tui: bootdisk: refactor Rc<RefCell<..>> type into custom type
Date: Tue, 25 Jul 2023 17:02:46 +0200	[thread overview]
Message-ID: <20230725150300.1389135-2-c.heiss@proxmox.com> (raw)
In-Reply-To: <20230725150300.1389135-1-c.heiss@proxmox.com>

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>
---
Changes v1 -> v2:
  * No changes

 proxmox-tui-installer/src/views/bootdisk.rs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/proxmox-tui-installer/src/views/bootdisk.rs b/proxmox-tui-installer/src/views/bootdisk.rs
index a018e71..0b0a9f8 100644
--- a/proxmox-tui-installer/src/views/bootdisk.rs
+++ b/proxmox-tui-installer/src/views/bootdisk.rs
@@ -20,9 +20,13 @@ use crate::{
 };
 use crate::{setup::ProxmoxProduct, InstallerState};

+/// 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,
 }

 impl BootdiskOptionsView {
@@ -545,14 +549,14 @@ impl ViewWrapper for ZfsBootdiskOptionsView {
     cursive::wrap_impl!(self.view: MultiDiskOptionsView<FormView>);
 }

-fn advanced_options_view(disks: &[Disk], options: Rc<RefCell<BootdiskOptions>>) -> impl View {
+fn advanced_options_view(disks: &[Disk], options_ref: BootdiskOptionsRef) -> impl View {
     Dialog::around(AdvancedBootdiskOptionsView::new(
         disks,
-        &(*options).borrow(),
+        &(*options_ref).borrow(),
     ))
     .title("Advanced bootdisk options")
     .button("Ok", {
-        let options_ref = options.clone();
+        let options_ref = options_ref.clone();
         move |siv| {
             let runinfo = siv
                 .user_data::<InstallerState>()
--
2.41.0





  reply	other threads:[~2023-07-25 15:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-25 15:02 [pve-devel] [PATCH installer v2 0/3] fix #4856: tui: bootdisk: use correct defaults in advanced dialog Christoph Heiss
2023-07-25 15:02 ` Christoph Heiss [this message]
2023-07-25 15:02 ` [pve-devel] [PATCH installer v2 2/3] tui: bootdisk: rename `disks` parameter to `avail_disks` Christoph Heiss
2023-07-25 15:02 ` [pve-devel] [PATCH installer v2 3/3] fix #4856: tui: bootdisk: use correct defaults in advanced dialog Christoph Heiss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230725150300.1389135-2-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal